def ceildiv(a: int, b: int) -> int: return (a + b - 1) // b INF = 1 << 60 D = int(input()) H1 = int(input()) H2 = int(input()) H3 = int(input()) # a > b > c にするのに必要な操作回数 def f(a, b, c): if D == 0: if a > b > c >= 0: return 0 return -1 res = 0 if a <= b: x = ceildiv(b-a, D) res += x b = max(0, b - x * D) if a == b: res += 1 b -= D if b <= c: x = ceildiv(c-b, D) res += x c = max(0, c - x * D) if b == c: res += 1 c -= D if a > b > c >= 0: return res return -1 #print(f'>> {a=} {b=} {c=} {res=}') #return res ans = INF # 真ん中が一番低い、または一番高い for a, b, c in [(H2, H1, H3), (H2, H3, H1), (H1, H3, H2), (H3, H1, H2)]: # print() # print(f'{a=} {b=} {c=}') res = f(a, b, c) if res == -1: continue ans = min(ans, res) if ans == INF: print(-1) else: print(ans)