def min_moves(gx, gy): # ルークの手数 if gx == 0 and gy == 0: rook_moves = 0 elif gx == 0 or gy == 0: rook_moves = 1 else: rook_moves = 2 # ビショップの手数 if (gx + gy) % 2 != 0: bishop_moves = float('inf') # 不可能 elif gx == 0 and gy == 0: bishop_moves = 0 elif gx == gy or gx == -gy: bishop_moves = 1 else: bishop_moves = 2 # 両方のうち最小の手数を返す return min(rook_moves, bishop_moves) # 入力例 gx, gy = map(int, input().split()) print(min_moves(gx, gy))