#include<cstdio>
#define ll long long
using namespace std;
int main()
{
    ll n,x;
    while(~scanf("%I64d%I64d",&n,&x))
    {
        if(x*2==n)printf("%I64d\n",3*(n/2));
        else printf("%I64d\n",3*(n-1));
}
