#include <bits/stdc++.h>
#define REP(i,n,N) for(int i=n;i<N;i++)
#define p(S) cout<<(S)<<endl
#define ck(a,b) (0<=(a)&&(a)<(b))
using namespace std;

bool bb[7400000];
void bb_hurui(int m,int n){
	int a=0;
	for(int i=m;a<n;i++){
		if(bb[i]) {
			continue;
		}
		for(int j=i;j<7400000;j+=i){
			bb[j]=true;
		}
		a++;
	}

}
int main(){
	int m,n;
	while(cin>>m>>n,n){
		memset(bb,false,sizeof(bb));
		bb_hurui(m,n);
		REP(i,m,7400000){
			if(!bb[i]){
				p(i);
				break;
			}
		}
	}
	return 0;
}