#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, k, i, s = 0, j, a, c, d, mas[100001] = {0}, b;
  cin >> a >> b;
  n = round(sqrt(a));
  for (i = 1; i <= n; ++i) {
    if (a % i == 0) {
      s++;
      mas[s] = i;
      s++;
      mas[s] = a / i;
    }
    if (i * i == a) s--;
  }
  sort(mas + 1, mas + s + 1);
  if (s < b)
    cout << -1;
  else
    cout << mas[b];
}
