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