#include <iostream>
#include <vector>
#define repeat(i,n) for (int i = 0; (i) < (n); ++(i))
using namespace std;
const int size = 7368791 + 1;
int main() {
    while (true) {
        int m, n; cin >> m >> n;
        if (m == 0 and n == 0) break;
        vector<bool> used(size);
        int j = m;
        repeat (i,n) {
            while (used[j]) ++ j;
            for (int k = j; k < used.size(); k += j) {
                used[k] = true;
            }
        }
        while (used[j]) ++ j;
        cout << j << endl;
    }
    return 0;
}

