#include<iostream>
#include<vector>
#define MAX 1e7
using namespace std;

int main(){
  int n, m;
  while(std::cin >> m >> n){
    vector<bool> isBoring(MAX, false);
    if(n == 0 and m == 0)break;
    int mini = m;
    for (int i = 0; i < n; i++) {
      while(isBoring[mini] == true) mini++;
      for (int j = mini; j < MAX; j+=mini) {
        isBoring[j] = true;
      }
    }
    int ans = 0;
    while(isBoring[ans] == false)ans++;
    while(isBoring[ans] == true)ans++;
    std::cout << ans << std::endl;
  }
  return 0;
}