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