N=int(input()) ANS=0 for i in range(1,10**6): x=str(i)*3 if int(x)<=N: ANS+=1 print(ANS)