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