m, d = map(int, input().split()) print(-1 if m == 4 and d == 1 else m + d)