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