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