#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int N, X;
  cin >> N >> X;
  if (N % 2 == 1) {
    cout << (N / 2 * 6) << endl;
  } else {
    cout << 3 * ((N / 2) + abs(N / 2 - X)) << endl;
  }
}
