n = int(input()) i = '1' s = 0 while n >= int(i*3): s += 1 i = str(int(i)+1) print(s)