#include <bits/stdc++.h>
using namespace std;
int main() {
  long double n, x;
  cin >> n >> x;
  long double ans = 0;
  long double t = x, c = n - x;
  bool con = true;
  while (con) {
    ans += 3 * t;
    if (c / t < 2) {
      c = t;
      t /= 2;
      if (t < 1) con = false;
    } else {
      c -= t;
    }
  }
  cout << ans;
}
