#include<iostream>
using namespace std;
int main() {
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int n, k;
cin >> n >> k;
int count = 0;
for (int i = 1; i <= n; i++) {
if (n % i == 0) {
count++;
if (count == k) {
cout << i << "\n";
return 0;
}
}
}
cout << -1 << "\n";
return 0;
}
I2luY2x1ZGU8aW9zdHJlYW0+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgppbnQgbWFpbigpIHsKICAgIGlvc19iYXNlOjpzeW5jX3dpdGhfc3RkaW8oMCk7IGNpbi50aWUoMCk7IGNvdXQudGllKDApOwogICAgCiAgICBpbnQgbiwgazsKICAgIGNpbiA+PiBuID4+IGs7CiAgICBpbnQgY291bnQgPSAwOyAgCiAgICBmb3IgKGludCBpID0gMTsgaSA8PSBuOyBpKyspIHsKICAgICAgICBpZiAobiAlIGkgPT0gMCkgewogICAgICAgICAgICBjb3VudCsrOyAgCiAgICAgICAgICAgIGlmIChjb3VudCA9PSBrKSB7CiAgICAgICAgICAgICAgICBjb3V0IDw8IGkgPDwgIlxuIjsgIAogICAgICAgICAgICAgICAgcmV0dXJuIDA7ICAKICAgICAgICAgICAgfQogICAgICAgIH0KICAgIH0KICAgIGNvdXQgPDwgLTEgPDwgIlxuIjsgCiAgICByZXR1cm4gMDsKfQo=