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