RT
#include<bits/stdc++.h>
using namespace std;
queue<int>arr[1000005];
long long n,k,d=0;
int main()
{
cin>>n>>k;
for(int i=2;i<=n;i++)
arr.push(i);
while(true)
{
long long p=arr.front(),e;
arr.pop();
e=arr.front();
while(arr.front()!=e)
{
if(arr.front()%p==0)
{
d++;
if(d==k)
{
cout<<arr.front();
return 0;
}
arr.pop();
}
else
{
arr.push(arr.front());
arr.pop();
}
}
}
return 0;
}