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