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