#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, k;
  cin >> n >> k;
  vector<long long> v;
  vector<long long> v1;
  set<long long> s;
  for (long long i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      v.push_back(i);
      s.insert(i);
      if (s.find(n / i) == s.end()) v1.push_back(n / i);
    }
  }
  long long cnt = 0;
  long long ans = -1;
  long long i = 0;
  while (cnt < v.size()) {
    cnt++;
    if (k == cnt) {
      ans = v[i];
      break;
    }
    i++;
  }
  long long j = 0, p = 0;
  sort(v1.begin(), v1.end());
  while (cnt != k && p < v1.size()) {
    cnt++;
    if (cnt == k) {
      ans = v1[j];
      break;
    }
    j++;
    p++;
  }
  cout << ans << endl;
}
