n,x,y,X,Y=map(int,input().split())
diff_x=abs(X-x)
diff_y=abs(Y-y)
diff=max(diff_x,diff_y)
value=[]
for c in range(diff+1):
	a=(diff_x-c)/(2*n)
	b=(diff_y-c)/(2*n)
	v=abs(a)+abs(b)+abs(c)
	value.append(v)
print(int(min(value)))