#include <bits/stdc++.h>
using namespace std;
long long N, x;
int main() {
  scanf("%lld%lld", &N, &x);
  if (N & 1ll) {
    cout << (N - 1ll) * 3ll << endl;
    return 0;
  }
  cout << abs(x - N / 2ll) * 3ll + N / 2ll * 3ll << endl;
  return 0;
}
