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