program abc136b
   implicit none
   integer :: n
   integer :: digit, counter

   read(*,*) n

   digit = int(log10(real(n))) + 1


   if ( digit == 6 ) then
      write(*,*) 90909
      stop
   endif

   counter = 0
   if ( digit == 5 ) then
      counter =  (n - 9999)
      counter = counter + 909
   else if (digit == 4) then
      counter = 909
   else if ( digit == 3) then
      counter =  (n - 99) + 9
   else if ( digit == 2) then
      counter = 9
   else if (digit == 1 ) then
      counter = n
   end if

   write(*,*) counter

end program abc136b
