def test(n)
  puts 90909 if n == 100000
  puts (10000..n).size + 909 if n.between?(10000,99999)
  puts (100..n).size + 9 if n.between?(10,9999) 
  puts (1..n).size if n.between?(1,9) 
end
test(gets.to_i)
