#include <bits/stdc++.h>
using ll = long long;
using namespace std;
const ll mod = 1000000007;
const ll INF = 1 << 30;
const ll INF2 = 9000000000000000000LL;
bool fl = true;
;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
struct edge {
  ll to, cost;
};
int main() {
  ll n, x;
  cin >> n >> x;
  if (n % 2 == 1) {
    cout << 6 + (n - 3) / 2 * 6 << endl;
  } else {
    ll c = 3 + (n - 2) / 2 * 3;
    cout << c + abs(n / 2 - x) * 3 << endl;
  }
}
