A, B = map(int, input().split()) x = -1 if B == 0: x = 1 elif B != 0 and A == -1: x = 2 print(x)