#include <bits/stdc++.h>
using namespace std;
long long dx[] = {-1, 0, 1, 0};
long long dy[] = {0, 1, 0, -1};
long long spf[10];
long long dist[1001];
void sieve() {
  long long i, j;
  for (i = 0; i < 10; i++) spf[i] = i;
  for (i = 4; i < 10; i += 2) spf[i] = 2;
  for (i = 3; i * i < 10; i++) {
    if (spf[i] == i) {
      for (j = i * i; j < 10; j += i) {
        if (spf[j] == j) spf[j] = i;
      }
    }
  }
}
bool isvowel(char c) {
  switch (c) {
    case 'a':
    case 'e':
    case 'i':
    case 'o':
    case 'u':
    case 'y':
      return true;
    default:
      return false;
  }
}
bool cmp(pair<long long, long long> x, pair<long long, long long> y) {
  return x.first > y.first;
}
long long isPrime(long long n) {
  for (long long i = 2; i <= sqrt(n); i++) {
    if (n % i == 0) {
      return i;
    }
  }
  return n;
}
long long sum(long long n) {
  long long ans = 0;
  while (n > 0) {
    long long d = n % 10;
    ans += d;
    n /= 10;
  }
  return ans;
}
vector<long long> adj[5001];
vector<long long> adj1[5001];
long long sub[1001];
long long dist1[1001];
long long vis1[1001];
long long cnt;
struct x {
  long long b;
  long long c;
  long long d;
};
long long vis[21][21];
long long n, m;
string a, b;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t;
  t = 1;
  while (t--) {
    long long n, k;
    cin >> n >> k;
    set<long long> s;
    for (long long i = 1; i <= sqrt(n); i++) {
      if (n % i == 0) {
        s.insert(n / i);
        s.insert(i);
      }
    }
    long long n1 = s.size();
    if (n1 < k) {
      cout << "-1"
           << "\n";
      return 0;
    }
    vector<long long> v;
    for (auto j : s) {
      v.push_back(j);
    }
    cout << v[k - 1] << "\n";
  }
  return 0;
}
