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

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


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

ll rec(ll n,ll m){
    if(n==1 and m==1)
        return 1ll;

    ll ans = 0;
    if(n > m){
        if(dp[n / 2][m] == 0){
            dp[n / 2][m] = rec(n / 2, m);
        }
        ans += dp[n / 2][m];

        if(n & 1){
            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][m];
        }
    }else{
        if(dp[n][m / 2] == 0){
            dp[n][m / 2] = rec(n, m / 2);
        }
        ans += dp[n][m / 2];

        if(m & 1){
            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];
        }

    }

    return ans + n * m;
}

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

    return 0;
}
