https://www.acmicpc.net/problem/5692
from sys import stdin
an=[]
while True:
a=int(stdin.readline())
if a==0: break
count=2
num=1
sum=0
while a>0:
n=a%10
sum+=n*num
a//=10
num*=count
count+=1
an.append(sum)
for i in range(len(an)): print(an[i])