#include <bits/stdc++.h>
using namespace std;
template <class S, class T>
istream& operator>>(istream& is, pair<S, T>& p) {
  return is >> p.first >> p.second;
}
const double EPS = 1e-10;
const double PI = acos(-1.0);
const long long MOD = 1e9 + 7;
int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  long long N, X;
  cin >> N >> X;
  if (X * 2 == N) {
    cout << N / 2 * 3 << endl;
  } else
    cout << 3 * (N - 1) << endl;
  return 0;
}
