#include <bits/stdc++.h>
using namespace std;
long long n, k, i, j, num = 0, sq;
static int ans[10000000];
void planb() {
  for (i = 1, j = 1; i <= sq; i++) {
    if (n % i == 0) ans[j++] = i;
  }
  if (ans[k] != 0)
    cout << ans[k] << endl;
  else if (k <= j * 2 - 2)
    cout << n / ans[2 * j - k - 1] << endl;
  else
    cout << "-1" << endl;
}
int main() {
  cin >> n >> k;
  if (k > 10000000) {
    cout << "-1" << endl;
    return 0;
  }
  sq = sqrt((double)n);
  if (sq * sq == n) {
    for (i = 1, j = 1; i <= sq; i++) {
      if (n % i == 0) ans[j++] = i;
    }
    if (ans[k] != 0)
      cout << ans[k] << endl;
    else if (k <= j * 2 - 3)
      cout << n / ans[j * 2 - 2 - k] << endl;
    else
      cout << "-1" << endl;
  } else
    planb();
  return 0;
}
