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