def min_moves(Gx, Gy): rook_moves = 0 if Gx != 0: rook_moves += 1 if Gy != 0: rook_moves += 1 bishop_moves = 2 if abs(Gx) == abs(Gy): bishop_moves = 1 if Gx == 0 and Gy == 0: return 0 return min(rook_moves, bishop_moves) Gx, Gy = map(int, input().split()) print(min_moves(Gx, Gy))