// Arup Guha
// 6/13/2024
// Solution to Kattis Problem: Reseto
// https://open.kattis.com/problems/reseto

using namespace std;
#include <bits/stdc++.h>

int main() {

    int n, k;
    cin >> n >> k;

    vector<bool> sieve(n+1, true);

    // Cross is how many crossed off, res is the answer.
    int cross = 0, res = -1;

    // Run sieve.
    for (int i=2; i<=n; i++) {

        // Skip these.
        if (!sieve[i]) continue;

        // Special cross off.
        cross++;
        if (cross == k) {
            res = i;
            break;
        }

        // Cross offs.
        for (int j=2*i; j<=n; j+=i) {

            // It only counts if this was previously true.
            if (sieve[j]) {
                sieve[j] = false;
                cross++;

                // We got a hit, get out.
                if (cross == k) {
                    res = j;
                    break;
                }
            }
        }

        // Get out!
        if (res != -1) break;
    }

    // Ta da!
    cout << res << endl;
    return 0;
}
