#include <bits/stdc++.h>
using namespace std;

int main(void){
	int m, n;
	
	while(cin >> m >> n, m+n){
		vector<int> v (7368791);
		int now = m, cnt = 0;
		while(1){
			v[now] = true;
			for(int i = 2; i*now <= 7368791; ++i){
				v[now*i] = true;
			}
			while(v[now]) now++;
			cnt++;
			if(cnt == n)break;
		}
		cout << now << endl;
	}
	return 0;
}
