#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void checkmin(T &a, T b) {
  if (b < a) a = b;
}
template <class T>
inline void checkmax(T &a, T b) {
  if (b > a) a = b;
}
template <class T>
inline T abs(T x) {
  return x < 0 ? -x : x;
}
template <class T>
inline T extgcd(T a, T b, T &x, T &y) {
  int d = a;
  if (b != 0) {
    d = extgcd(b, a % b, y, x);
    y -= (a / b) * x;
  } else {
    x = 1;
    y = 0;
  }
  return d;
}
template <class T>
inline T mypow(T n, T k) {
  T res = 1;
  for (T i = 0; i < k; ++i) res *= n;
  return res;
}
template <class T>
inline T mod_pow(T x, T n, T mod) {
  T res = 1;
  while (n) {
    if (n & 1) res = res * 1LL * x % mod;
    x = x * 1LL * x % mod;
    n >>= 1;
  }
  return res;
}
template <class T>
inline T add(int *b, int i, T x, int N) {
  while (i <= N) {
    *(b + i) += x;
    x += (x & (-x));
  }
}
template <class T>
inline T getsum(int *b, int i) {
  T res = 0;
  while (i > 0) {
    res += *(b + i);
    i -= (i & (-i));
  }
  return res;
}
template <class T>
inline void add_mod(T &a, int mod = -1) {
  if (mod == -1) mod = 1e9 + 7;
  while (a >= mod) a -= mod;
  while (a < 0) a += mod;
}
const int maxn = 1e5 + 10;
const int mod = (int)1e9 + 7;
const int inf = 2147483647;
const int sigma_size = 26;
const long long LLMAX = 0x7fffffffffffffffLL;
const long long LLMIN = 0x8000000000000000LL;
const int INF = 2147483647;
const int IMIN = 0x80000000;
const long long MOD = 1000000007LL;
const double pi = acos(-1.0);
inline int pdt(int x, int y) {
  int ret;
  __asm__ __volatile__("\tmull %%ebx\n\tdivl %%ecx\n"
                       : "=d"(ret)
                       : "a"(x), "b"(y), "c"(MOD));
  return ret;
}
long long gcd(long long a, long long b, long long *x, long long *y) {
  long long tx, ty;
  long long g;
  if (b > a) return gcd(b, a, y, x);
  if (b == 0) {
    *x = 1;
    *y = 0;
    return a;
  }
  g = gcd(b, a % b, &tx, &ty);
  *x = ty;
  *y = tx - floor(a / b) * ty;
  return g;
}
int a[maxn];
int main() {
  ios_base::sync_with_stdio(0);
  long long n;
  int k;
  cin >> n >> k;
  vector<long long> div;
  div.clear();
  for (long long i = 1; i * i <= n; ++i) {
    if (n % i == 0) {
      div.push_back(i);
      div.push_back(n / i);
    }
  }
  sort((div).begin(), (div).end()),
      div.erase(unique((div).begin(), (div).end()), div.end());
  int sz = div.size();
  if (sz < k)
    cout << -1 << endl;
  else
    cout << div[k - 1] << endl;
  return 0;
}
