#include "bits/stdc++.h"

using namespace std;

static bool years[7368792];

void solve()
{
  int m, n;
  while(cin >> m >> n && m && n) {
    memset(years, 1, sizeof years);
    for(int i = m; i < 7368792; i++) {
      if(years[i]) {
        --n;
        if(n == -1) {
          cout << i << "\n";
          break;
        }
        for(int j = i + i; j < 7368792; j += i) {
          years[j] = false;
        }
      }
    }
  }
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie();
  solve();
}