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