#include<stdio.h>

int main(void)
{
	int m, n;	/* ??\??????????????? m:????????????????????? 2???100, n:???????????° 1???500000 */
	int count;	/* ????????§????????´??°??????????????? */
	int used = 0;	/* ???????????????????????????????????????????????° */
	int j;

	while (1) {
		scanf("%d %d", &m, &n);
		if (m == 0 && n == 0) {
			break;
		}
		else {
			count = m;
			while (n >= used) {
				for (j = m; j <= count; j++) {
					//printf("count = %d, used = %d\n", count, used);
					if (count > m) {
						if ((count % j) == 0) {
							break;
						}
						if (j == (count - 1)) {
							used++;
						}
					}
					else {
						used++;
						//printf("check\n");
					}
				}
				count++;
				//printf("???: count = %d, used = %d\n", count - 1, used);
			}
			printf("%d\n", count - 1);
		}

		/* ????????? */
		used = 0;
	}


	return 0;
}