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