include Math
n = gets.chomp.to_i
digit_cout = log10(n).to_i
ans = 0
case digit_cout
when 5
  ans = 90909
when 4
  ans = (10000..n).count + (100..999).count + (1..9).count
when 3
  ans = (100..999).count + (1..9).count
when 2
  ans = (100..n).count + (1..9).count
when 1
  ans = (1..9).count
when 0
  ans = (1..n).count
end
p ans
