N = gets.to_i
if N >= 1 && N <= 9
  puts N
elsif N >= 10 && N <= 99
  puts 9
elsif N >= 100 && N <= 999
  puts N - 99 + 9
elsif N >= 1_000 && N <= 9_999
  puts 9 + (999 - 100 + 1)
elsif N >= 10_000 && N <= 99_999
  puts N - 9999 + 900 + 9
elsif N == 100_000
  puts 90_909
end
