N = int(input()) i = 1 while int(str(i)*3) <= N: i += 1 print(i-1)