#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;
// Iterate from 1 to sqrt(n)
for (int i = 1; i * i <= n; i++) {
if (n % i == 0) {
count++; // Found a divisor
if (count == k) {
cout << i << "\n"; // Print the k-th smallest divisor
return 0;
}
// Check the paired divisor n/i, only if it's different
if (i != n / i) {
count++;
if (count == k) {
cout << n / i << "\n"; // Print the paired divisor
return 0;
}
}
}
}
// If the k-th divisor doesn't exist
cout << -1 << "\n";
return 0;
}
I2luY2x1ZGU8aW9zdHJlYW0+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgppbnQgbWFpbigpIHsKICAgIGlvc19iYXNlOjpzeW5jX3dpdGhfc3RkaW8oMCk7IGNpbi50aWUoMCk7IGNvdXQudGllKDApOwogICAgCiAgICBpbnQgbiwgazsKICAgIGNpbiA+PiBuID4+IGs7CiAgICBpbnQgY291bnQgPSAwOwoKICAgIC8vIEl0ZXJhdGUgZnJvbSAxIHRvIHNxcnQobikKICAgIGZvciAoaW50IGkgPSAxOyBpICogaSA8PSBuOyBpKyspIHsKICAgICAgICBpZiAobiAlIGkgPT0gMCkgewogICAgICAgICAgICBjb3VudCsrOyAgLy8gRm91bmQgYSBkaXZpc29yCiAgICAgICAgICAgIGlmIChjb3VudCA9PSBrKSB7CiAgICAgICAgICAgICAgICBjb3V0IDw8IGkgPDwgIlxuIjsgIC8vIFByaW50IHRoZSBrLXRoIHNtYWxsZXN0IGRpdmlzb3IKICAgICAgICAgICAgICAgIHJldHVybiAwOyAgCiAgICAgICAgICAgIH0KCiAgICAgICAgICAgIC8vIENoZWNrIHRoZSBwYWlyZWQgZGl2aXNvciBuL2ksIG9ubHkgaWYgaXQncyBkaWZmZXJlbnQKICAgICAgICAgICAgaWYgKGkgIT0gbiAvIGkpIHsKICAgICAgICAgICAgICAgIGNvdW50Kys7CiAgICAgICAgICAgICAgICBpZiAoY291bnQgPT0gaykgewogICAgICAgICAgICAgICAgICAgIGNvdXQgPDwgbiAvIGkgPDwgIlxuIjsgIC8vIFByaW50IHRoZSBwYWlyZWQgZGl2aXNvcgogICAgICAgICAgICAgICAgICAgIHJldHVybiAwOyAgCiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICB9CiAgICB9CgogICAgLy8gSWYgdGhlIGstdGggZGl2aXNvciBkb2Vzbid0IGV4aXN0CiAgICBjb3V0IDw8IC0xIDw8ICJcbiI7CiAgICByZXR1cm4gMDsKfQo=