#include <bits/stdc++.h>
long long a[10000005];
int main() {
  long long n, k;
  scanf("%lld %lld", &n, &k);
  long long c = 0;
  for (long long i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      a[c++] = i;
      if (i * i != n) a[c++] = n / i;
    }
  }
  long long temp;
  for (long long i = 0; i < c; i++) {
    for (long long j = i + 1; j < c; j++) {
      if (a[i] > a[j]) {
        temp = a[i];
        a[i] = a[j];
        a[j] = temp;
      }
    }
  }
  if (c < k)
    printf("-1");
  else
    printf("%lld", a[k - 1]);
  return 0;
}
