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