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