#include <iostream>
#include <bits/stdc++.h>
using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    long long n, x;
    cin >> n >> x;
    if(n % 2 == 0)
        if(x == n/2){
            cout << 3*n/2 << endl;
            return 0;
        }
    cout << n + (n-1)*2 - 1 << endl;
    return 0;
}
