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