The merchant’s riddle

A group of pilgrims, together on their way to Santiago, decided to sug- gest riddles to each other to make the journey more pleasant. Between them there was a merchant, a pensive and organised man that handled numbers with solvency. When his turn to propose a riddle arrived, he made them see that, in total, they were part of a group of 12 hikers and, hence, they could walk on a single line, or in groups of two, three, four, six or even build a human wall of 12 people. In addition, he explained, if they were less people it would be impossible to make groups in 6 different ways. “I know that these stony paths — he told them — are narrow in a lot of stages but, leaving that aside, what is the smallest size that our erudite group should have so that we can walk exactly in 64 different ways?” Only when all of them obtained the Compostelana did the merchant decide to, as a present, reveal the truth. Input The program must read, from the standard input, a set of test cases. Each of them will consist of a single number 1 ≤ n ≤ 1, 000, 000, 000. The input will end with a ‘0’, which should not be processed. Output For each test case, the program will write the smallest number of pilgrims that should be part of the group so that they can be structured in exactly n different ways. Consider that it makes no sense to make groups of more than 1,000,000,000 people, so if the answer exceeds this number, ‘+INF’ should be written instead. Sample Input 6 37 64 0 Sample Output 12 +INF 7560