#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, k, x, i;
  cin >> n >> k;
  vector<long long> v, v1;
  x = n / 2;
  for (long long i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      if (i == n / i) {
        v.push_back(i);
      } else {
        v.push_back(i);
        v.push_back(n / i);
      }
    }
  }
  sort(v.begin(), v.end());
  if (v.size() >= k)
    cout << v[k - 1] << endl;
  else
    cout << -1 << endl;
  return 0;
}
