def min_moves(Gx, Gy): # 检查 Gx 和 Gy 的奇偶性 if Gx == 0 and Gy == 0: return 0 elif (Gx % 2 == 0 and Gy % 2 == 0) or (Gx % 2 == 1 and Gy % 2 == 1): return 1 else: return 2 # 读取输入 Gx, Gy = map(int, input().split()) # 计算并输出最小步数 print(min_moves(Gx, Gy))