input_word = input()
tmp_list = input_word.split(" ")
N = int(tmp_list[0])
Y = int(tmp_list[1]) * 2 - 1
output = [[ 0 for i in range(2*N) ] for j in range(2*N)]
X = 0
flag = 1
output[Y][X] = 1

while True:
  if flag == 1:
    if Y == 2*X + 1:
      if output[Y+1][Y+1] == 0:
        Y, X = Y+1, Y+1
        flag = 2
      else:
        flag = 4
    else:
      if output[Y-1][2*X+1] == 1 and output[Y-1][2*X+2] == 1 and output[Y+1][2*X+2] == 1 and output[Y+1][2*X+3] == 1:
        flag = 4
      elif output[Y-1][2*X+1] == 1 and output[Y+1][2*X+3] == 1: 
        Y, X = Y+1, 2*X+2
        flag = 2
      elif output[Y-1][2*X+2] == 1 and output[Y+1][2*X+2] == 1:
        Y, X = Y-1, 2*X+1
        flag = 3
      else:
        X += 1
  elif flag == 2:
    if Y == 2*N -2:
      if output[Y][X-1] == 0:
        Y,X = Y,X-1
        flag = 3
      else:
          flag = 4
    else:
      if output[Y][X-1] == 1 and output[Y+1][X//2-1] == 1 and output[Y+1][X//2] == 1 and output[Y+2][X+1] == 1:
        flag = 4
      elif output[Y][X-1] == 1 and output[Y+2][X+1] == 1:
        Y,X = Y+1,X//2
        flag = 1
      elif output[Y+1][X//2-1] == 1 and output[Y+1][X//2] == 1:
        Y,X = Y,X-1
        flag = 3
      else:
        Y += 2
  else:
    if X == 1:
      if output[Y-1][0] == 0:
        Y,X = Y-1,0
        flag = 1
      else:
          flag = 4
    else:
      if output[Y-2][X-1] == 1 and output[Y-1][(X-1)//2-1] == 1 and output[Y-1][(X-1)//2] == 1 and output[Y][X-1] == 1:
        flag = 4
      elif output[Y-1][(X-1)//2-1] == 1 and output[Y-1][(X-1)//2] == 1:
        X -= 1
        flag = 2
      elif output[Y-2][X-1] == 1 and output[Y][X-1] == 1:
        Y,X = Y-1,(X-1)//2
        flag = 1
      else:
        Y -= 2
        X -= 2
        
  if flag == 4:
    break
  else:
    output[Y][X] = 1

res = 0

for i in output:
  for j in i:
    res += j
print(res)