#include <bits/stdc++.h>
using namespace std;
long long int k, n, i, p, x, y;
long long int ami[10000000];
long long int amina[5000000];
int main() {
  while (cin >> n >> k) {
    i = 1;
    p = 0;
    x = 0;
    y = 0;
    while (i * i <= n) {
      if (n % i == 0) {
        ami[x++] = i;
        if (i != n / i) {
          amina[y++] = n / i;
        }
      }
      i++;
    }
    while (y--) {
      ami[x++] = amina[y];
    }
    i = 0;
    if (x >= k) {
      cout << ami[k - 1] << endl;
    } else {
      cout << "-1\n";
    }
  }
  return 0;
}
