n = gets.chomp.to_i

one = 9-1+1
thr = 999-100+1
fiv = 99999 - 10000 + 1
result = 0
case n.to_s.length
when 6 then
  result = one + thr + fiv
when 5
  result = one + thr + fiv - (99999 - n)
when 4 then
  result = one + thr
when 3
  result = one + thr - (999 - n)
when 2 then
  result = one
when 1 then
  result = one - (9 - n)
end
puts result