#include <stdio.h>
#define ll long long
#define rep(i,l,r)for(ll i=l;i<r;i++)

//間に合う？
#define LIMIT 7400000
int*p;
int main(){
	ll m,n;
	while(scanf("%lld%lld",&m,&n),m){
		p=calloc(LIMIT+10,sizeof(int));
		rep(i,m,LIMIT)if(!p[i]){
			if(!n--){
				printf("%lld\n",i);
				break;
			}else{
				for(int j=i+i;j<LIMIT;j+=i)p[j]=1;
			}
		}
		free(p);
	}
}
