#include <iostream>
constexpr int NUM = 7368792;
bool number[NUM];
int main()
{
	int m, n;
	while (std::cin >> m >> n && n && m) {
		for (int i = 0; i < NUM; i++) number[i] = true;
		for (int i = 0; i < n + 1; i++) {
			while (!number[m++]) {}
			number[--m] = 0;
			int year = m;
			while ((year += m) < NUM) number[year] = 0;
		}
		std::cout << m << std::endl;
	}
	return 0;
}