#include <bits/stdc++.h>
using namespace std;
int main() {
  long long N, X;
  cin >> N >> X;
  if (N % 2 == 0)
    cout << 3 * (N / 2 + abs(N / 2 - X)) << endl;
  else if (X > N / 2)
    cout << 3 * (X / 2 * 2) << endl;
  else if (X <= N / 2)
    cout << 3 * (N - (X - 1) / 2 * 2 - 1) << endl;
}
