#!/usr/bin/python N = int(input()) top = N // 1000000001 count = 0 for i in range(1, top+1): tmp = str(i) if tmp == tmp[::-1]: count += 1 print(count)