d = int(input()) inf = 10 ** 18 H = [0] * 3 for i in range(3): H[i] = int(input()) def check(A, d): if d == 0: if A[0] > A[1] > A[2]: return 0 else: return inf cnt = 0 if A[1] >= A[0]: cnt = (A[1] - A[0] + 1 + d - 1)//d A[1] -= cnt * d if A[1] <= 0: return inf if A[2] >= A[1]: cnt += (A[2] - A[1] + 1 + d - 1)//d return cnt ans = inf ans = min(ans, check([H[1], H[0], H[2]], d)) ans = min(ans, check([H[1], H[2], H[0]], d)) ans = min(ans, check([H[2], H[0], H[1]], d)) ans = min(ans, check([H[0], H[2], H[1]], d)) print(ans) if ans != inf else print(-1)