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