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