Vanya got an important task — he should enumerate books in the library and label each book with its number. Each of the *n* books should be assigned with a number from 1 to *n*. Naturally, distinct books should be assigned distinct numbers.

Vanya wants to know how many digits he will have to write down as he labels the books.
The first line contains integer *n* (1 ≤ *n* ≤ 10<sup class="upper-index">9</sup>) — the number of books in the library.
# coding=utf-8
n=int(input())
while n!=0:
    t2=n
    t1=n+1
    s=0
    while t2>0:
        s+=t2%2
        t2=t2//2
    while True:
        t=0
        t11=t1
        while t11>0:
            t+=t11%2
            t11=t11//2
            if t==s:
                print(t1)
                break
            t1+=1
        n=int(input())
 	    		   		 	 				 			 	