N = gets.chomp.to_i

if N == 100000
  p 90000 + 900 + 9
elsif N <= 99999 && N >= 10000
  p (N - 9999) + 900 + 9
elsif N <= 9999 && N >= 1000
  p 900 + 9
elsif N <= 999 && N >= 100
  p (N - 99) + 9
elsif N <= 99 && N >= 10
  p 9
else
  p N
end
