Bamboo Blossoms

Choose n lifetimes of at least m years, one per block, so the first year with no blossom in any block is as late as possible; report that year.

Medium6Number theoryGreedyMathNo attempts yetTime limit2sMemory limit512 MB

Problem

Bamboo lives for decades, then flowers once at the end of its life, sets seed, and dies. Dr. ACM, a biologist, fell for the bamboo blossoms he saw while traveling and decided to build a garden where bamboo flowers every year. After a long breeding program he found a way to create varieties whose lifetime is any value he specifies.

Call a variety that flowers kk years after sowing a kk-year bamboo. A kk-year bamboo flowers kk years later, sets seed, and dies, and the next generation grown from that seed flowers another kk years later. Sowing the seeds of a kk-year bamboo therefore gives blossoms every kk years. With a 15-year bamboo the flowers come in year 15, year 30, year 45, and every other multiple of 15.

The garden is split into nn blocks and each block holds a single variety. Two blocks may hold the same variety. Short-lived varieties are hard to breed, so Dr. ACM uses only varieties whose lifetime is mm years or more, and he sows every block this year and never sows again. He accepts a few flowerless years at the start, but after that he wants at least one block in bloom every year.

Let year yy mean yy years from now. A block planted with a variety of lifetime kk blooms in every year that is a multiple of kk. The waiting period Dr. ACM accepts is the first mm years, so the blooming has to start in year mm.

However he plants, a year with no blossom in any block eventually arrives. Plant so that the first such year comes as late as possible, and report which year it is.

Input

The input has at most 50 datasets. Each dataset is one line with two integers mm and nn.

mm (2m1002 \le m \le 100) is the shortest lifetime among the varieties Dr. ACM can use, in years, and nn (1n5000001 \le n \le 500000) is the number of blocks.

A line holding two zeros marks the end of the input, and that line is not a dataset.

Output

For each dataset print one line with the first year that has no blossom, counted in years from now, under the best planting.

The dataset with m=2m = 2 and n=500000n = 500000 gives the largest answer.