#include <bits/stdc++.h>
using namespace std;
long long n, m, i, j, k, l, t;
long long a[1000005], b;
bool q = false;
int main() {
  cin >> n >> k;
  for (i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      t++;
      a[t] = i;
    }
    if (i * i == n) q = true;
  }
  if (q == false) {
    if (k <= t)
      cout << a[k] << endl;
    else if (k > t && k <= 2 * t)
      cout << n / a[t - (k - t) + 1] << endl;
    else
      cout << -1 << endl;
  } else {
    if (k <= t)
      cout << a[k] << endl;
    else if (k > t && k <= (2 * t - 1))
      cout << n / a[t - (k - t)] << endl;
    else
      cout << -1 << endl;
  }
  return 0;
}
