#include<stdio.h>
int main(){
  int n,m,i,c,j;
  while(scanf("%d %d",&n,&m),n){
    char p[8000010]={};
    c=0;
    for(i=n;c<=m;i++){
      if(p[i]==0){//printf("%d\n",i);
	for(j=i;j<8000000;j+=i)p[j]=1;
	c++;
      }
    }//printf("\n");
    printf("%d\n",i-1);
  }
  return 0;
}