import sys d = input() h = [] for i in xrange(3): h.append(input()) def is_finish(H): if (len(set(H)) == 3 and (min(H) == H[1] or max(H) == H[1])): return True else: return False def is_impossible(H): if d == 0: return True else: return False def mod_min(H): res = 0 if H[0] == H[2]: H[0] = max(0, H[0] - d) res += 1 #print H diff = abs(H[1] - min(H[0], H[2])) H[1] -= (diff / d + 1) * d H[1] = max(H[1], 0) if len(set(H)) == 3 and min(H) == H[1]: return res + diff / d + 1 return 1e+18+7 def mod_max(H): diff = abs(H[1] - max(H[0] ,H[2])) i = 0 if max(H[0],H[2]) == H[0] else 2 H[i] -= (diff / d + 1) * d H[i] = max(H[i], 0) if len(set(H)) == 3 and max(H) == H[1]: #print "max" return diff / d + 1 return 1e+18+7 def solve(): if is_finish(h): print 0 return if is_impossible(h): print -1 return res1 = mod_min(h[:]) res2 = mod_max(h[:]) if min(res1, res2) != 1e+18 + 7: print min(res1, res2) else: print -1 return def main(): solve() solve()