n = gets.to_i
n /= 1000000001
a = [0, 10, 19, 109, 199, 1099, 1999, 10999, 19999] #回文数の総数
ans = a[n.to_s.size - 1]
x = (n.to_s.size + 1) / 2
[*0..9].repeated_permutation(x).to_a.each do |b|
    s = ''
    if n.to_s.size % 2 == 0
        s = b.join + b.join.reverse
    else
        c = b.pop
        s = b.join + c.to_s + b.join.reverse
    end
    y = s.to_i
    next if y.to_s.size < n.to_s.size || y > n
    ans += 1
end
ans -= 1
p ans