def rook_moves(x, y): if x == 0 and y == 0: return 0 elif x == 0 or y == 0: return 1 else: return 2 def bishop_moves(x, y): if x == 0 and y == 0: return 0 if (x + y) % 2 != 0: return float('inf') # unreachable if x == y or x == -y: return 1 return 2 # Read input import sys x, y = map(int, sys.stdin.read().split()) # Output minimum number of moves print(min(rook_moves(x, y), bishop_moves(x, y)))