#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, t = 0;
  bool a[7777777];
  while (cin >> n >> m, n) {
    t = 0;
    memset(a, false, sizeof(a));
    for (int j = n; j < 7777777; j++) {
      if (!a[j]) {
        for (int k = j; k < 7777777; k += j) {
          a[k] = true;
        }
        t++;
      }
      if (m == 1) break;
      if (m != 1 && t == m) break;
    }
    for (int i = n; i < 7777777; i++) {
      if (!a[i]) {
        cout << i << endl;
        break;
      }
    }
  }
  return 0;
}
