def f(x): return int(str(x)*3) N=int(input()) x=0 while f(x+1)<=N: x+=1 print(x)