#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define fi first
#define se second
#define sz size()
#define pb push_back()

const int N = 1e6+1;

map<ll,map<ll,ll>> dp;

ll rec(ll n,ll m){
    if(n==1 and m==1)
        return 1;
    ll mxn=max(n,m);
    ll ans=0;
    if(mxn&1){
        if(n>m){
            if(dp[n/2][m]==0){
                dp[n/2][m]=rec(n/2,m);
                ans+=dp[n/2][m];
            }
            else
                ans+=dp[n/2][m];
            if(dp[n/2+1][m]==0){
                dp[n/2+1][m]=rec(n/2+1,m);
                ans+=dp[n/2+1][m];
            }
            else
                ans+=dp[n/2+1][m];
        }
        else{
            if(dp[n][m/2]==0){
                dp[n][m/2]=rec(n,m/2);
                ans+=dp[n][m/2];
            }
            else
                ans+=dp[n][m/2];
            if(dp[n][m/2+1]==0){
                dp[n][m/2+1]=rec(n,m/2+1);
                ans+=dp[n][m/2+1];
            }
            else
                ans+=dp[n][m/2+1];
        }
    }
    else{
        if(n>m){
            if(dp[n/2][m]==0){
                dp[n/2][m]=rec(n/2,m);
                ans+=2*dp[n/2][m];
            }
            else
                ans+=2*dp[n/2][m];
        }
        else{
            if(dp[n][m/2]==0){
                dp[n][m/2]=rec(n,m/2);
                ans+=2*dp[n][m/2];
            }
            else
                ans+=2*dp[n][m/2];
        }
    }
    return ans + n * m;
}

int main(){
    ll n,m;
    cin>>n>>m;
    cout<<rec(n,m);


}
