#include <bits/stdc++.h>
using namespace std;
long long n, k;
deque<long long> q;
signed main() {
  cin >> n >> k;
  for (register long long i = sqrt(n); i >= 1; i--) {
    if (n % i == 0) {
      if (i * i != n)
        q.push_front(i), q.push_back(n / i);
      else
        q.push_front(i);
    }
  }
  if (q.size() < k)
    cout << -1;
  else
    cout << q[k - 1];
  return 0;
}
