M, D = map(int, input().split()) if M == 4 and D == 1: print(-1) else: print(M + D)