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