#include <iostream>

using namespace std;
#define N 7500000

bool years[N+10];

int main(){
    int m,n;
    while(cin>>m>>n){
        if(m==0 && n==0){
            break;
        }
        for(int i = m; i <= N; i++){
            years[i]=true;
        }
        

        for(int i = m; i <= N; i++){
            if(years[i]){
                if(n == 0){
                    cout<<i<<endl;
                    break;
                }
                n--;

                for(int j = i + i; j <= N; j += i){
                    years[j] = false;
                }
            }
        }
    }
}