n= int(input()) x=n//(10**9+1) cnt=0 for i in range(1,x+1): istr=str(i) if istr==istr[::-1]: cnt+=1 print(cnt)