begin repeat var n,f,g,i,s:comp=1;read(n);repeat f:=f*i+f;s:=s+n mod f div g*10pow i;g:=f;inc(i)until i=18;writeln(s-1)until 1=0end.