#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, k, j = 0, l = -1, m;
  cin >> n >> k;
  long long int arr[1000000];
  if (k > n) {
    cout << l;
    return 0;
  }
  for (long long int i = 2; i <= sqrt(n); i++) {
    if (n % i == 0 && i * i != n) {
      arr[j++] = i;
      arr[j++] = n / i;
    }
    if (i * i == n) arr[j++] = i;
  }
  arr[j++] = 1;
  if (n != 1) arr[j++] = n;
  arr[j] = 0;
  sort(arr, arr + j + 1);
  if (j < k)
    cout << l;
  else
    cout << arr[k];
  return 0;
}
