#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, x, ans = 0;
  cin >> n >> x;
  ans = x * 3;
  long long i = 2, a = 3;
  while (1) {
    if (n < a) break;
    ans += i * 3 * (n / a);
    i++;
    a = a + a + 1;
  }
  cout << ans << endl;
  return 0;
}
