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