#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, k, c = 0;
  vector<long long int> vec;
  scanf("%lld", &n);
  scanf("%lld", &k);
  for (long long int i = 1; i * i <= n; ++i) {
    if (n % i == 0) vec.push_back(i);
  }
  long long int last = vec.back(), div = vec.size() * 2;
  if (last * last == n) div--;
  if (k > div)
    printf("-1\n");
  else if (k <= vec.size()) {
    printf("%lld\n", vec[k - 1]);
  } else {
    printf("%lld\n", n / vec[div - k]);
  }
  return 0;
}
