#include <iostream>
#include <map>
#include <vector>
using namespace std;

map<pair<long long, long long>, long long> dp;

long long rec(long long a, long long b) {
    if (dp[{a, b}] != 0) {
        return dp[{a, b}];
    }
    if (a < b) swap(a, b);
    int i = 1;
    while(i * 2 < a) {
        i *= 2;
    }
    long long ans = a * b + rec(a - i, b) + rec(i, b);
    dp[{a, b}] = ans;
    dp[{b, a}] = ans;
    return dp[{a, b}];
}

int main() {
    dp[{ 1, 1}] = 1;
  long long n, m;
  cin >> n >> m;
  cout << rec(n,m);
}