#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;

bool ok[7368792];
int main() {
	int m, n;
	while (scanf("%d%d", &m, &n), m) {
		memset(ok, 0, sizeof(ok));
		int cnt = 0;
		for (int i = m;; i++) {
			if (!ok[i]) {
				if (++cnt > n) {
					printf("%d\n", i); break;
				}
				for (int j = i; j <= 7368791; j += i)ok[j] = true;
			}
		}
	}
}