// Aizu 1610: Bamboo Blossoms
// 2017.9.21 bal4u@uu

#include <stdio.h>

#define MAX  7368792
char tbl[MAX + 5], *pmax = tbl + MAX;

int main()
{
	int m, n, i, j, cno = 0;
	register char *p, *q;

	while (scanf("%d%d", &m, &n) && m) { cno++;
		for (i = 0; i < n; i++) {
			for (j = m, q = p = tbl + m; p < pmax; p += j) *p = cno;
			while (*q++ == cno) m++;
		}
		printf("%d\n", m);
	}
	return 0;
}