from numpy import array
N,X=list(map(int,input().split()))


'''
M[i段目][左からj]
0.右  (i,j+1)
1.左上 (i-1,j-1)
2.右上 (i-1,j+1)
3.左下(i+1,j)
4.右下(i+1,j+1)

'''
M =[[array([0,0]) for _ in range(n+1)] for n in range(N+1)]
#print(M)
#start M[X][0]
pos = array([X,0])
ans = 0
dist = array([0,1])
while not( ans and pos[0]==X and pos[1]==0):
    pos += dist
    ans += 1
    if pos[0] ==pos[1]:
        dist = array([1,0]) #dl
    elif pos[1]==0:
        dist = array([0, 1]) #r
    elif pos[0]==N:
        dist = array([-1, -1]) #ul

    if not M[pos[0]][pos[1]].any():
        M[pos[0]][pos[1]]= dist
    else:
        dist_tmp =M[pos[0]][pos[1]]
        dist = -dist-dist_tmp
        #r + dl -> ul
        #ul + r -> dl
    #print(M)
print(ans)