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