#include <bits/stdc++.h>
using namespace std;
vector<pair<long long, long long> > v;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n, k;
  cin >> n >> k;
  vector<long long> v1;
  for (long long i = 1; i <= sqrt(n); i++) {
    if (n % i == 0) {
      if (n / i == i) {
        v1.push_back(i);
        continue;
      }
      v1.push_back(i);
      v1.push_back(n / i);
    }
  }
  sort(v1.begin(), v1.end());
  if (k > v1.size()) {
    cout << "-1";
    return 0;
  }
  cout << v1[k - 1];
  return 0;
}
