A, B = [[i for i in input().strip().split(' ')] for _ in range(2)] print([B[0], -1, A[0]][1 if A[1] == B[1] else (int(A[1]) - int(B[1])) // abs(int(A[1]) - int(B[1])) + 1])