N=input() kosuu=int(N)//(10**9+1) ans_cnt=0 for i in range(1,kosuu+1): mystr=str(i) if mystr==mystr[::-1]: ans_cnt+=1 print(ans_cnt)