n=gets.chomp.to_i
t = n
max_value = {"s1": 9, "s3": 909}
kq = 0
stt = n.to_s.length
puts stt
if stt == 1
  kq = n
elsif(stt%2==0)
  kq = max_value["s#{stt-1}".to_sym]
elsif(stt%2==1)
  kq = max_value["s#{stt-2}".to_sym] + n + 1 - 10**(stt-1)
end
puts kq
