n = eval(input())



if len(n) == 1:

    print(n)

elif len(n) == 2:

    print((9))

elif len(n) == 3:

    print((9+(int(n)-100+1)))

elif len(n) == 4:

    print((909))

elif len(n) == 5:

    print((9+900+(int(n)-10000+1)))

elif len(n) == 6:

    print((90909))

import sys

stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)



i_i = lambda: int(i_s())

i_l = lambda: list(map(int, stdin.readline().split()))

i_s = lambda: stdin.readline().rstrip()



N = i_i()



l = len(str(N))



if l == 1 or l == 2:

    print((min(9, N)))

elif l == 3 or l == 4:

    print((min(9 + N - 100 + 1, 909)))

else:

    print((min(9 + 900 + N - 10000 + 1, 90909)))

n = eval(input())
if len(n) == 1:
    print(n)
elif len(n) == 2:
    print((9))
elif len(n) == 3:
    print((9 + (int(n) - 100 + 1)))
elif len(n) == 4:
    print((909))
elif len(n) == 5:
    print((9 + 900 + (int(n) - 10000 + 1)))
elif len(n) == 6:
    print((90909))

import sys

stdin = sys.stdin
sys.setrecursionlimit(10**7)
i_i = lambda: int(i_s())
i_l = lambda: list(map(int, stdin.readline().split()))
i_s = lambda: stdin.readline().rstrip()
N = i_i()
l = len(str(N))
if l == 1 or l == 2:
    print((min(9, N)))
elif l == 3 or l == 4:
    print((min(9 + N - 100 + 1, 909)))
else:
    print((min(9 + 900 + N - 10000 + 1, 90909)))

-n = eval(input()) -if len(n) == 1: -    print(n) -elif len(n) == 2: -    print((9)) -elif len(n) == 3: -    print((9 + (int(n) - 100 + 1))) -elif len(n) == 4: -    print((909)) -elif len(n) == 5: -    print((9 + 900 + (int(n) - 10000 + 1))) -elif len(n) == 6: -    print((90909)) +import sys + +stdin = sys.stdin +sys.setrecursionlimit(10**7) +i_i = lambda: int(i_s()) +i_l = lambda: list(map(int, stdin.readline().split())) +i_s = lambda: stdin.readline().rstrip() +N = i_i() +l = len(str(N)) +if l == 1 or l == 2: +    print((min(9, N))) +elif l == 3 or l == 4: +    print((min(9 + N - 100 + 1, 909))) +else: +    print((min(9 + 900 + N - 10000 + 1, 90909)))