#include <bits/stdc++.h>   using ll = long long;   using namespace std;   int main() {     ios::sync_with_stdio(false);     int N, K;     cin >> N >> K;     ll total = N + 1;     total += N;     total += min(2 * (K - 1) + (N - K), 2 * (N - K) + K - 1);     cout << total <<   n ;     return 0;   }   