n = int(input()) ans = 0 now = 1 t = str(now) + str(now) + str(now) while int(t)<=n: ans += 1 now += 1 t = str(now) + str(now) + str(now) print(ans)