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