#include <bits/stdc++.h>
const int INF = 2147483647;
const long long int MOD = 1000000007;
using namespace std;
int main() {
  long long int n, x;
  cin >> n >> x;
  if (n % 2LL == 0LL && n / 2LL == x) {
    cout << n / 2LL * 3LL << endl;
  } else {
    cout << 3LL * (n - 1LL) << endl;
  }
}
