def make_b_max(a,b,c,d):
    r = 0
    if a >= b:
        v = (a-b)//d + 1
        a = max(0,a-d*v)
        r += v
    if c >= b:
        v = (c-b)//d + 1
        c = max(0,c-d*v)
        r += v
    # b: maxになった
    if a != c: return r
    if a: return r+1
    else: return INF

def make_b_min(a,b,c,d):
    r = int(a==c)
    if a==c:
        a = max(a-d,0)
    x = min(a,c)
    if x <= b:
        v = (b-x)//d + 1
        b = max(0,b-d*v)
        r += v
    # b: minになった
    if a != b and c != b: return r
    else: return INF

d,a,b,c = map(int,open(0).read().split())
ans = INF = 1<<60
if d==0:
    if a != b != c != a and (a < b > c or a > b < c):
        print(0)
    else:
        print(-1)
    exit()

ans = min(ans,make_b_min(a,b,c,d))
ans = min(ans,make_b_max(a,b,c,d))
print(ans if ans != INF else -1)