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