#include <bits/stdc++.h>
using namespace std;
long long int a[10000005];
int main() {
  long long int n, k;
  cin >> n >> k;
  int num = 1;
  for (int i = 1; i <= sqrt(n); i++) {
    if (n % i == 0) a[num++] = i;
  }
  num--;
  if (a[num] * a[num] == n) {
    if (num * 2 - 1 < k)
      cout << "-1" << endl;
    else {
      if (num >= k)
        cout << a[k] << endl;
      else
        cout << n / a[2 * num - k] << endl;
    }
  } else {
    if (num * 2 < k) {
      cout << "-1" << endl;
      return 0;
    }
    if (num >= k)
      cout << a[k] << endl;
    else
      cout << n / a[2 * num - k + 1] << endl;
  }
  return 0;
}
