#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, k, idx = 0;
  cin >> n >> k;
  long long tab[16384];
  for (long long i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      tab[idx++] = i;
    }
  }
  set<long long> s;
  for (int i = 0; i < idx; i++) s.insert(tab[i]), s.insert(n / tab[i]);
  if (k <= s.size()) {
    set<long long>::iterator it = s.begin();
    advance(it, k - 1);
    cout << *it;
  } else
    cout << -1;
}
