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