let [n, k] = require("fs").readFileSync(0,"utf8").toString().trim().split(' ').map(Number);
let i=1;
while(i<=n){
    if(n%i==0) {
        k--;
        if(k==0) break;
    }
    i++;
}

if(k!=0) console.log(0);
else console.log(i);