x,y = input().split() Gx, Gy = int(x),int(y) if Gx == 0 or Gy == 0: rook_moves = 1 else: rook_moves = 2 if (Gx + Gy) % 2 != 0: bishop_moves = float('inf') else: if Gx == Gy or Gx == -Gy: bishop_moves = 1 else: bishop_moves = 2 print(min(rook_moves, bishop_moves))