#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, k;
  cin >> n >> k;
  vector<long long int> divisors;
  for (long long int i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      divisors.push_back(i);
    }
  }
  if (k <= divisors.size()) {
    cout << divisors[k - 1] << "\n";
  } else if (pow(divisors[divisors.size() - 1], 2) == n) {
    if (k <= 2 * (divisors.size() - 1) + 1) {
      k -= divisors.size();
      cout << n / divisors[divisors.size() - 1 - k] << "\n";
    } else
      cout << "-1\n";
  } else {
    if (k <= 2 * divisors.size()) {
      k -= divisors.size();
      cout << n / divisors[divisors.size() - k] << "\n";
    } else
      cout << "-1\n";
  }
  return 0;
}
