1. 程式人生 > >2018山東大學acm校賽B

2018山東大學acm校賽B

YangFan is a wayward boy who likes to count in his own way.

The number he writes may be 0 or 1 for each digit, and the last non-zero digit may be 2, and the value of the k-th digit xk denotes CodeCogsEqn.gif.

For example:

CodeCogsEqn(1).gif

                   CodeCogsEqn(2).gif

Input

The input contains one or more lines, each line contains an integer n. If n = 0 means the input is over, otherwise n is a number written by YangFan.

Output

For each number written by YangFan, output its decimal representation. After conversion to decimal, n < 2^31.

Sample Input 1 

100000002
110
11102
0

Sample Output 1

513
10
55