n=int(input()) ans=0 for i in range(1,int(n**(1/3))+10): tmp=int(str(i)*3) if tmp<=n: ans+=1 print(ans)