#include <bits/stdc++.h>
using namespace std;
long long n, k;
vector<long long> v;
int main() {
  scanf("%lld", &n);
  scanf("%lld", &k);
  for (long long i = 1; i <= sqrt(n); i++) {
    if (n % i == 0) {
      v.push_back(i);
      if (i != n / i) v.push_back(n / i);
    }
  }
  sort(v.begin(), v.end());
  if (v.size() < k)
    printf("-1\n");
  else
    printf("%lld\n", v[k - 1]);
  return 0;
}
