#include <iostream>
#include <cmath>

using namespace std;

#define MAX 7368791

int main(){
  int m, n;
  bool flag[MAX];

  while(cin >> m >> n, m||n){
    for(int i = 0 ; i <= MAX ; i++) flag[i] = false;
    for(int i = m ;; i++){
      if(!flag[i]){
    if(n == 0){
      cout << i << endl;
      break;
    }else{
      n--;
      for(int j = i ; j <= MAX ; j+=i){
        flag[j] = true;
      }
    }
      }
    }
  }
}
