N,K = map(int,raw_input().split()) cnt = 0 ans = 1 while N >= K: N -= K cnt += 1 if N%cnt == 0: ans = cnt print ans