#include <bits/stdc++.h>

#define fi first
#define se second

#define pw(x) (1LL << x)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define sz(x) (int)(x).size()

using namespace std;

template < typename T >
bool umn (T& a, T  b) {return a > b ? a = b, 1 : 0;}
template < typename T >
bool umx (T& a, T  b) {return a < b ? a = b, 1 : 0;}

using ll = long long;
using ld = long double;

const int N = 1e6 + 5;

ll res = 0, n, m;
map <ll, ll > mp[N];
ll solve (int n, int m) {

    if (!n || !m) return 0;

    if (max (n, m) == 1) return 1LL * n * m;

    if (mp[n].find (m) != mp[n].end()) {
        return mp[n][m];
    }


    ll res = 0;
    if (n > m) {
        res += solve (n / 2, m);
        res += solve (n / 2 + (n&1), m);
    }  else{
        res += solve (n, m / 2);
        res += solve (n, m / 2 + (m & 1));
    }
    mp[n][m] = res +1LL * n * m;
    return res + 1LL * n * m;
}

int main() {
#ifdef localy
    freopen ("input.txt", "r", stdin);
    freopen ("output.txt", "w", stdout);
#endif // localy
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    cin >> n >> m;
    cout << solve (n, m) << "\n";
    return 0;
}
