#include <bits/stdc++.h>
const int md = 1000000007;
using namespace std;
int main() {
  deque<long long> d;
  long long n, k;
  scanf("%lld %lld\n", &n, &k);
  int MAX = (int)sqrt(n) + 1;
  for (int i = 1; i <= MAX; i++) {
    if (n % i == 0) {
      d.push_back(i);
      d.push_back(n / i);
    }
  }
  sort(d.begin(), d.end());
  vector<long long> ok;
  while (d.size() > 0) {
    long long elem = d.front();
    d.pop_front();
    while (d.size() > 0 && d.front() == elem) d.pop_front();
    ok.push_back(elem);
  }
  if (k > (int)ok.size()) {
    printf("-1");
  } else {
    printf("%lld", ok[k - 1]);
  }
  return 0;
}
