#include <bits/stdc++.h>
using namespace std;
const long long P = 1000000007;
const long long INF = 1LL << 60;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
int main() {
  cout << fixed << setprecision(10);
  long long N, X;
  cin >> N >> X;
  if (N % 2 == 0 && X == N / 2) {
    cout << (N - 1) * 2 << endl;
    return 0;
  }
  cout << (N - 1) * 3 << endl;
  return 0;
}
