number, n=map(int, input().split()) num=[] for i in range(1, number+1): if number%i==0: num.append(i) if n>len(num): print(0) else: print(num[n-1])