program bbb

implicit none
integer :: n,i,co,res
integer,dimension(6) :: a

read*, n

a(1)=int(n/(10**5))
a(2)=int(n/(10**4)-a(1)*10**1)
a(3)=int(n/(10**3)-a(1)*10**2-a(2)*10**1)
a(4)=int(n/(10**2)-a(1)*10**3-a(2)*10**2-a(3)*10**1)
a(5)=int(n/(10**1)-a(1)*10**4-a(2)*10**3-a(3)*10**2-a(4)*10**1)
a(6)=int(n/(10**0)-a(1)*10**5-a(2)*10**4-a(3)*10**3-a(4)*10**2-a(5)*10**1)

do i=1,6
if (a(i)==0) cycle
co=i
exit
end do

res=0

if (co==5) res=9
if (co==3) res=909
if (co==1) res=90909
if (co==6) res=a(6)
if (co==4) then
res=((a(4)-1)*10**2+a(5)*10+a(6)+10)
end if
if (co==2) then
res=((a(2)-1)*10**4+a(3)*10**3+a(4)*10**2+a(5)*10+a(6)+910)
end if

write(*,'(i0)') res

end program