n=int(input());c=0 for x in range(1000000001,-~n,1000000001): if str(x)==str(x)[::-1]:c+=1 print(c)