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