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