import sys def II(): return int(sys.stdin.readline()) def solve(): n=II() ans=0 for k in range(1,10): h=(k+1)//2 for l in range(10**(h-1),10**h): s=str(l) a=int(s+s[::-1][k&1:])*1000000001 if a>n:return ans ans+=1 return ans print(solve())