Prime Kebab Menu

Prime is an unusual but efficient Kebab restaurant. Prime has many small tables, which allow it to serve groups of various sizes without problems. We went to Prime last weekend and saw one small table with 3 people, another one with 5 people, and another with 14 people — the servers simply rearrange the tables as they see fit to cater to those groups. One unusual feature of Prime is that each client may choose only one dish from their large menu. Even more strangely, we noticed that the waiters of Prime relay a whole order to the kitchen with just one number! I saw the group of 3 people ask for the first, third, and fifth dishes in the menu, and their waiter relayed this to the kitchen as 110. When the group of five asked for dishes number 1, 2, 3, 4, and 5, their waiter said only 2310. Finally, when the group of 14 requested the first dish 10 times and the second one 4 times, I heard their waiter say 82 944. Amazingly, when the respective waiters came back with the meals, all orders were correctly fulfilled! This strange numerical code is still incomprehensible to me. I have found, through some research, that the waiters never say 1. Of course this doesn’t help me much and I still have lots of questions, such as: if a waiter relays just one number to the kitchen, how do the chefs calculate the number of clients in the table? I am confident that, if you can answer this for me, then I can fully crack the restaurant code. Your task is to write a program that outputs the number of clients in the table given the number relayed by a waiter. Input The input consists of several test cases. Each test case is a line containing an integer 1 < n < 1014, which is a number relayed by a waiter. The end of the input is given by n = 1, which should not be processed as a test case. Output For each test case, print a line with the number of clients in the group. Sample Input 110 82944 1 Sample Output 3 14