d = int(input()) H1 = int(input()) H2 = int(input()) H3 = int(input()) impossible = 9999999999 ans = impossible def Kadomatsu(a,b,c): if a == b or b == c or c == a: return False if a<=b and b <= c: return False if a>= b and b >= c: return False return True def A(a, b, c): result = 0 if a == c: if a <= d: return impossible else: a = max(0, a - d) result += 1 m = min(a, c) if b >= m: sa = b - m bb = sa // d + 1 b = max(0,b-bb*d) result += bb if Kadomatsu(a,b,c): return result else: return impossible def B(a, b, c): result = 0 if b == 0: return impossible if a >= b: sa = a - b aa = sa // d + 1 result += aa a = max(0, a - aa * d) if c >= b: sa = c - b cc = sa // d + 1 result += cc c = max(0, c - cc * d) if a == c: if a == 0: return impossible result +=1 if Kadomatsu(a,b,c): return result else: return impossible if Kadomatsu(H1,H2,H3): print(0) else: if d == 0: print(-1) else: ans = min(A(H1,H2,H3),B(H1,H2,H3)) print(-1 if ans == impossible else ans)