#include <bits/stdc++.h>
using namespace std;
long long n, k;
int main() {
  cin >> n >> k;
  int d = 0;
  for (long long i = 1; i * i <= n; ++i) {
    if (n % i != 0) continue;
    if (d / 2 + 1 == k) {
      cout << i << endl;
      return 0;
    }
    if (i * i < n) {
      d += 2;
    } else {
      d++;
    }
  }
  if (k > d) {
    puts("-1");
    return 0;
  }
  int c = 0;
  for (long long i = 1; i * i <= n; ++i) {
    if (n % i != 0) continue;
    c++;
    if (d - c + 1 == k) {
      cout << n / i << endl;
      return 0;
    }
  }
}
