A, B = map(int, input().split())
if A == 1 and B == 2:
    print(3)
elif A == 1 and B == 3:
    print(2)
elif A == 2 and B == 1:
    print(3)
elif A == 1 and B == 2:
    print(3)
elif A == 3 and B == 2:
    print(1)
elif A == 2 and B == 3:
    print(1)
else:
    print(-1)
