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