import sys read=sys.stdin.buffer.read readline=sys.stdin.buffer.readline readlines=sys.stdin.buffer.readlines d=int(readline()) h=list(map(int, read().split())) INF=10**10 ans=INF import itertools for p in itertools.permutations(range(3)): if p[0]!=1 and p[2]!=1: continue if d==0: if x[p[0]]>x[p[1]] and x[p[1]]>x[p[2]]: print(0) exit() else: continue x=h[:] c1=max(0, (x[p[1]]-x[p[0]])//d+1) x[p[1]]-=c1*d if x[p[1]]<=0: continue c2=max(0, (x[p[2]]-x[p[1]])//d+1) x[p[2]]-=c2*d ans=min(ans, c1+c2) if ans==INF: print(-1) else: print(ans)