#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
const long long N = (long long)1e5 + 100;
const int M = (int)1e4 + 4;
const int INF = (int)0x3f3f3f3f;
long long n, x;
int Solve() {
  std::ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> n >> x;
  long long res = (3 * x) + (n - x) + 3 * (x - 1);
  cout << res << endl;
  return 0;
}
int main() {
  Solve();
  return 0;
}
