#!/usr/bin/python3 # -*- coding: utf-8 -*- # † inf = int(1e9) + 100 def bye(s): print(s) exit(0) def ok(x, y, z): ok1 = x > y and y < z ok2 = x < y and y > z return x!=z and (ok1 or ok2) def count(my, your, d): if your==0: return inf if my < your: return 0 return (my - your + d) // d def cut(my, d, times): return max(0, my-d*times) d = int(input()) h1 = int(input()) h2 = int(input()) h3 = int(input()) assert 0 <= d <= int(1e9) assert 0 <= h1 <= int(1e9) assert 0 <= h2 <= int(1e9) assert 0 <= h3 <= int(1e9) if ok(h1, h2, h3): bye('0') if d==0: bye('-1') r1 = 0 x, y, z = h1, h2, h3 if x==z: x = cut(x, d, 1) r1 += 1 p = count(x, y, d) r1 += p x = cut(x, d, p) q = count(z, y, d) r1 += q z = cut(z, d, q) if not ok(x, y, z): r1 = inf r2 = 0 x, y, z = h1, h2, h3 if x==z: x = cut(x, d, 1) r2 += 1 p = count(y, x, d) r2 += p y = cut(y, d, p) q = count(y, z, d) r2 += q cut(y, d, q) if not ok(x, y, z): r2 = inf res = min(r1, r2) if res >= inf: res = -1 print(res)