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