There are K lemurs on Madagascar and Kevin has N bananas. He has to give away all his bananas to lemurs. Lemurs are happy if all of them get the same number of bananas (even if they don't get any). In one minute Kevin can do one of the following:
 Find one banana. 
 Discard one banana (eat). 
 Increase a population of lemurs on Madagascar by one. 
 If there are at least two lemurs remove one of them from Madagascar (don't ask how). 

Help Kevin and find the minimum number of minutes Kevin needs to satisfy all the lemurs.

Input format:

The only line of the input contains two space-separated integers N and K.

Output format:

Output the single integer -- the minimum number of minutes.

Constraints:
1 ≤ K,N ≤ 10^5
K, N ≤ 50 in test data worth 33% of all points

SAMPLE INPUT
47 17

SAMPLE OUTPUT
2
s=f=1000000
n,k=map(int,raw_input().split())
if(n%k==0):
	print 0
else:
	j=k
	for i in range(1000000):
		a=n//k
		b=(n//k)+1
		x=b*k-n
		y=n-(a*k)
		g=min(x,y)
		d=k-j
		if((g+d)<f):
			f=g+d
			#print g,d
		k+=1
	k=j	
	for l in range(1000000):
		#print "tatti"
		if k<=0:
			break
		#print k
		a=n//k
		b=(n//k)+1
		x=(b*k)-n
		y=n-(a*k)
		g=min(x,y)
		d=j-k
		if((g+d)<f):
			f=g+d
			#print g,d
		k-=1
	print f