n=gets.chomp.split(' ').map{|n| n.to_i}
s = 1
max_value = {s1: 9, s3: 900}
kq = 0
while n/10 > 0
  n = n /10
  s+= 1
end
if(s%2==0)
  kq = maxvalue["s"+s-1]
else
  kq = maxvalue["s"+s-1] + n - 10**s
puts kq