N = gets.to_i

answer = if N <= 99
           [N, 9].min
         elsif N <= 9999
           [N - 99, 900].min + 9
         elsif N <= 999999
           [N - 9999, 90000].min + 9 + 900
         end

puts answer
