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