#include<bits/stdc++.h>
using namespace std;
int main(){
int n,k,cnt=0;
cin>>n>>k;
bool b[114514514]={};
memset(b,true,sizeof(b));
for(int i=2;i<=n;i++){
if(b[i]==true){
for(int j=i;j<=n;j+=i){
if(b[j]==true){
cnt++;
b[j]=false;
}
if(cnt==k){
cout<<j;
return 0;
}
}
}
}
return 0;
}