begin repeat var i,k,n:comp=0;read(n);for i:=10downto 1do k:=i*(k+n div 10pow i mod 10);writeln(k)until 0>0end.