D, A, B, C = input(), input(), input(), input() if A > C: A, C = C, A if A == 0 or C == 0: print -1 elif A == B == C: print 3 if B > D else -1 elif A < B < C: m1 = (B-A)/D + ((B-A)%D==0) m2 = (C-B)/D + ((C-D)%D==0) if (C-A)%D == 0 and A+D == B: m2 += 1 print min(m1, m2) elif A == B < C: print 1 elif A < B == C: if C - D != A: print 1 else: print 2 else: print 0