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