#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, k, i;
  while (scanf("%lld %lld", &n, &k) != EOF) {
    vector<long long int> v;
    for (i = 1; i * i <= n; i++) {
      if (n % i == 0) {
        v.push_back(i);
        if ((n / i) != i) v.push_back(n / i);
      }
    }
    sort(v.begin(), v.end());
    if (v.size() < k) {
      cout << "-1" << endl;
    } else {
      printf("%lld\n", v[k - 1]);
    }
  }
  return 0;
}
