#include <bits/stdc++.h>
using namespace std;
long long k, res, a[1111], n;
set<long long> s;
int main() {
  cin >> n >> k;
  for (long long i = 1; i <= sqrt(n); i++) {
    if (n % i == 0) s.insert(i), s.insert(n / i);
  }
  for (long long i : s) {
    res++;
    if (res == k) {
      cout << i;
      return 0;
    }
  }
  cout << -1;
}
