#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 17;
const int MOD = 1e9 + 7;
int main(int argc, char const *argv[]) {
  long long n, x;
  cin >> n >> x;
  if (n & 1 == 0 && x == n / 2)
    cout << x * 3 << endl;
  else
    cout << (n - 1) * 3 << endl;
  return 0;
}
