https://www.acmicpc.net/problem/5692
import java.util.*;
public class Main {
public static void main(String args[]) {
Scanner s=new Scanner(System.in);
for(;;){
int a=s.nextInt();
if(a==0) break;
int count=1;
int num=1;
int sum=0;
while(a>0){
int n=a%10;
sum+=n*num;
a/=10;
num*=++count;
}
System.out.println(sum);
}
}
}