N = gets.to_i

if N < 10
  puts N
elsif N < 100
  puts 9
elsif N < 1000
  puts (1..9).count + (100..N).count
elsif N < 10000
  puts (1..9).count + (100..999).count
elsif N < 100000
  puts (1..9).count + (100..999).count + (10000..N).count
elsif
  puts (1..9).count + (100..999).count + (10000..99999).count
end