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