#include <stdio.h>
#include <string.h>

#define GIVEN_VALUE 7400000

char data[GIVEN_VALUE];

int main(void) {
	int m, n;
	while (scanf("%d%d", &m, &n) == 2 && (m > 0 || n > 0)) {
		int i, j;
		int left = n;
		memset(data, 0, sizeof(data));
		for (i = m; ; i++) {
			if (!data[i]) {
				if (left > 0) {
					left--;
					for (j = i; j < GIVEN_VALUE; j += i) data[j] = 1;
				} else {
					printf("%d\n", i);
					break;
				}
			}
		}
	}
	return 0;
}