program main
  implicit none

  integer n, kt

  read(*,*)n
  kt = int(log(n))
  
  if (kt == 0) then
    write(*,*)n-1
    exit
  else if (kt == 1) then
    write(*,*)9
    exit
  else if (kt == 2) then
    write(*,*)9 + n - 101
    exit
  else if (kt == 3) then
    write(*,*)909
    exit
  else if (kt == 4) then
    write(*,*)909 + n - 1001
    exit
  else
    write(*,*)90909
  end if
end program main