#include <bits/stdc++.h>
using namespace std;
int chh;
long long n, x;
int main() {
  while (cin >> n >> x) {
    if (n % 2)
      cout << 3 * (n - 1) << '\n';
    else
      cout << n / 2 * 3 + abs(x - n / 2) * 3 << '\n';
  }
  return 0;
}
