#include <bits/stdc++.h>
using namespace std;
long long arr[50000];
int main() {
  long long n, k;
  while (cin >> n >> k) {
    long long cnt = 0;
    long double sq = sqrt((long double)n);
    long long res = -1;
    bool flag = false;
    for (long long i = 1; i <= sq; ++i) {
      if (n % i == 0) {
        arr[cnt++] = i;
        if (i == sq) flag = true;
      }
    }
    long long tot = 2 * cnt - flag;
    if (k > tot) {
      cout << -1 << endl;
    } else if (k > cnt) {
      cout << n / arr[tot - k] << endl;
    } else {
      cout << arr[k - 1] << endl;
    }
  }
  return 0;
}
