N,K=map(int,input().split()) for i in range(max(1,N//K),-1,-1): if(N%i==0): print(i) break