#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<ll, ll>;
using uc = unsigned char;
constexpr ll INF = 1LL << 62;
constexpr ll MOD = 1e9 + 7;
int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N, X;
  cin >> N >> X;
  if (N == X * 2) {
    cout << 3 * X << endl;
  } else {
    cout << 3 * (N - 1) << endl;
  }
  return 0;
}
