#include <bits/stdc++.h>
using namespace std;
const int N = 10005;
long long n, x;
long long a[N];
int main() {
  cin >> n >> x;
  long long res = x + (n - x);
  a[1] = a[2] = 1;
  for (int i = 3;; ++i) {
    if (i % 2 == 0 && n - (i / 2) * x <= 0) break;
    a[i] = a[i - 1] + a[i - 2];
    if (i & 1)
      res += x * 1ll * a[i];
    else
      res += (n - (i / 2) * x) * 1ll * a[i];
    if (i % 2 == 0 && n - (i / 2) * x == 1) break;
  }
  cout << res << endl;
  return 0;
}
