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