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