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