#include<stdbool.h>
int n,m;main(j){
  while(scanf("%d%d",&m,&n),n){
    bool b[1000000]={};
    for(;n!=0;n--){
      while(b[m])m++;
      for(j=2*m;j<1000000;j+=m)b[j]=1;
    }
    while(b[++m]);
    printf("%d\n",m);
  }
}