#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
int main() {
  long long n, x;
  cin >> n >> x;
  long long ans;
  if (n % 2 == 1)
    ans = (n / 2) * 6;
  else {
    ans = 3 * n / 2;
    long long gap = abs(n / 2 - x);
    ans += gap * 3;
  }
  cout << ans << endl;
}
