#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long n;
  cin >> n;
  ;
  long long m;
  cin >> m;
  ;
  set<long long> s;
  for (long long i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      s.insert(i);
      s.insert(n / i);
    }
  }
  if (s.size() < m) {
    cout << -1;
    return;
  }
  auto it = s.begin();
  for (long long i = 1; it != s.end() && i < m; it++, i++)
    ;
  cout << *(it);
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  solve();
  return 0;
}
