#include<iostream>

using namespace std;

constexpr int MAX_LEN = 7368791;

bool seeBamboo[MAX_LEN + 20] = { true, true, };

int main()
{
    int m, n;
    while(cin >> m >> n, (m + n))
    {
        fill(seeBamboo + m, seeBamboo + MAX_LEN, false);

        int num = m;

        for(int i = 0; i < n; i++)
        {
            while(seeBamboo[num])num++;
            for(int j = num; j < MAX_LEN; j += num)
            {
                seeBamboo[j] = true;
            }
        }

        int ans = num;
        while(seeBamboo[ans])ans++;
        cout << ans << endl;
    }

    return 0;
}