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