#include <stdio.h>
#include <stdlib.h>
#include<math.h>

#define NUM 7368791

int main(void)
{
	int m, n;
	int count = 0;
	int i, j;
	int *p;
	if ((p = malloc(sizeof(int) * NUM)) == NULL) {
		exit(EXIT_FAILURE);
	}
	for (i = 0; i < NUM; i++) {
		p[i] = 1;
	}
	
	int compare = (int)pow(NUM, (1.0 / 2.0));

	while (scanf("%d %d", &m, &n) == 2) {
		if (m == 0 && n == 0) {
			break;
		}
		else{
			/* m??\????????°?????????????????°?????????????????¨??? */
			for (i = m; i <= compare; i++) {
				/* i????????°???NUM???????°???????????????? */
				for (j = 2; NUM > (j * i); j++) {
					p[(i * j) - 1] = 0;
				}
			}
			
			for (i = m; ; i++) {
				if ((p[i - 1]) == 1) {
					count++;
				}
				if (count == (n + 1)) {
					printf("%d\n", i);
					break;
				}
			}
		}

		for (i = 0; i < NUM; i++) {
			p[i] = 1;
		}
		count = 0;
	}



	free(p);
	return 0;
}