#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  if (fopen("input.in", "r")) {
    freopen("input.in", "r", stdin);
    freopen("output.out", "w", stdout);
  }
  long long n, k;
  cin >> n >> k;
  long long a = sqrt(n);
  long long ct = 0;
  vector<long long> s;
  vector<long long> b;
  for (long long i = 1; i <= a; i++) {
    if (n % i == 0) {
      s.push_back(i);
      if (i * i != n) {
        b.push_back(n / i);
      }
    }
  }
  for (int i = b.size() - 1; i >= 0; i--) {
    s.push_back(b[i]);
  }
  if (s.size() < k) {
    cout << -1;
  } else
    cout << s[k - 1];
}
