#include<bits/stdc++.h>

#define reps(i,j,k) for(int i=j;i<k;i++)
#define rep(i,j) reps(i,0,j)
#define fs first
#define sc second
#define mk make_pair

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;

const int M = 7400000;
int v[M];
int main(){
	int n,m;
	while(cin >> m >> n, m){
		fill(v, v+M, 0);
		reps(i, m, M){
			if(!v[i]){
				for(int j=i+i; j< M; j+= i)v[j] = 1;
				n--;
			}
			if(n<0){
				cout << i <<endl;
				break;
			}
		}
	}
	return 0;
}