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