#P460. 练83.2 汽水瓶

练83.2 汽水瓶

Description

Here's a brain teaser: "A store has a rule: three empty soda bottles can be exchanged for one full bottle of soda. If Xiao Zhang has ten empty bottles, how many bottles of soda can she drink at most?" The answer is 55 bottles, as follows: first exchange 99 empty bottles for 33 full bottles, drink them, leaving 44 empty bottles. Then exchange 33 empty bottles for 11 full bottle, drink it, leaving 22 empty bottles. Then borrow one bottle from the store owner, drink it, and use the 33 empty bottles to exchange for one full bottle to return to the owner. If Xiao Zhang has nn empty bottles, how many bottles of soda can she drink at most?

Input Format

Each line contains a positive integer nn (1n1001 ≤ n ≤ 100), representing the number of empty bottles Xiao Zhang has. n=0n=0 indicates the end of input, and your program should not process this line.

Output Format

For each test case, output one line containing the maximum number of bottles of soda that can be drunk. If no bottles can be drunk, output 00.

Sample

3
10
81
0
1
5
40