def rook_moves(gx, gy): if gx == 0 and gy == 0: return 0 if gx == 0 or gy == 0: return 1 return 2 def bishop_moves(gx, gy): if (gx + gy) % 2 != 0: return float('inf') # không thể đến được if gx == 0 and gy == 0: return 0 if abs(gx) == abs(gy): return 1 return 2 def main(): gx, gy = map(int, input().split()) ans = min(rook_moves(gx, gy), bishop_moves(gx, gy)) print(ans) if __name__ == "__main__": main()