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