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