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