





'''simple docstring'''






from __future__ import annotations

from collections import defaultdict
from dataclasses import dataclass


@dataclass
class 	_lowercase    :
   _UpperCamelCase									= 42
   _UpperCamelCase									= None
   _UpperCamelCase									= None







def 				_lowerCamelCase(	)		->	TreeNode:
    return TreeNode(3     ,							TreeNode(9		)     ,							TreeNode(20     ,							TreeNode(15		)     ,							TreeNode(7		)		)		)
def 				_lowerCamelCase(	UpperCamelCase__     :			TreeNode		)		->	list[int]:

    def depth_first_search(
        UpperCamelCase__     :			TreeNode | None     ,							UpperCamelCase__     :			int     ,							UpperCamelCase__     :			list[int]		) -> None:
        if not root:
            return

        if depth == len(UpperCamelCase__		):
            right_view.append(root.val		)

        depth_first_search(root.right     ,							depth + 1     ,							UpperCamelCase__		)
        depth_first_search(root.left     ,							depth + 1     ,							UpperCamelCase__		)

    A							:							list				=    []
    if not root:
        return right_view

    depth_first_search(UpperCamelCase__     ,							0     ,							UpperCamelCase__		)
    return right_view
def 				_lowerCamelCase(	UpperCamelCase__     :			TreeNode		)		->	list[int]:

    def depth_first_search(
        UpperCamelCase__     :			TreeNode | None     ,							UpperCamelCase__     :			int     ,							UpperCamelCase__     :			list[int]		) -> None:
        if not root:
            return

        if depth == len(UpperCamelCase__		):
            left_view.append(root.val		)

        depth_first_search(root.left     ,							depth + 1     ,							UpperCamelCase__		)
        depth_first_search(root.right     ,							depth + 1     ,							UpperCamelCase__		)

    A							:							list				=    []
    if not root:
        return left_view

    depth_first_search(UpperCamelCase__     ,							0     ,							UpperCamelCase__		)
    return left_view
def 				_lowerCamelCase(	UpperCamelCase__     :			TreeNode		)		->	list[int]:

    def breadth_first_search(UpperCamelCase__     :			TreeNode     ,							UpperCamelCase__     :			list[int]		) -> None:
        A							:							Any				=    [(root, 0)]
        A							:							Dict				=    defaultdict(UpperCamelCase__		)

        while queue:
            A							:							Union[str, Any]				=    queue.pop(0		)
            A,						A							:							List[Any]				=    first

            lookup[hd].append(node.val		)

            if node.left:
                queue.append((node.left, hd - 1)		)
            if node.right:
                queue.append((node.right, hd + 1)		)

        for pair in sorted(lookup.items()     ,							key=lambda UpperCamelCase__		: each[0]		):
            top_view.append(pair[1][0]		)

    A							:							list				=    []
    if not root:
        return top_view

    breadth_first_search(UpperCamelCase__     ,							UpperCamelCase__		)
    return top_view
def 				_lowerCamelCase(	UpperCamelCase__     :			TreeNode		)		->	list[int]:
    from collections import defaultdict

    def breadth_first_search(UpperCamelCase__     :			TreeNode     ,							UpperCamelCase__     :			list[int]		) -> None:
        A							:							List[str]				=    [(root, 0)]
        A							:							Any				=    defaultdict(UpperCamelCase__		)

        while queue:
            A							:							int				=    queue.pop(0		)
            A,						A							:							List[Any]				=    first
            lookup[hd].append(node.val		)

            if node.left:
                queue.append((node.left, hd - 1)		)
            if node.right:
                queue.append((node.right, hd + 1)		)

        for pair in sorted(lookup.items()     ,							key=lambda UpperCamelCase__		: each[0]		):
            bottom_view.append(pair[1][-1]		)

    A							:							list				=    []
    if not root:
        return bottom_view

    breadth_first_search(UpperCamelCase__     ,							UpperCamelCase__		)
    return bottom_view


if __name__ == "__main__":
     import doctest

     doctest.testmod()







'''simple docstring'''






def 				_lowerCamelCase(	UpperCamelCase__     :			int = 1_000		)		->	int:
    A							:							Optional[Any]				=    [0, 3, 3, 5, 4, 4, 3, 5, 5, 4, 3, 6, 6, 8, 8, 7, 7, 9, 8, 8]
    # number of letters in twenty, thirty, ..., ninety (0 for numbers less than
    # 20 due to inconsistency in teens)
    A							:							Tuple				=    [0, 0, 6, 6, 5, 5, 5, 7, 6, 6]

    A							:							str				=    0

    for i in range(1     ,							n + 1		):
        if i < 1_000:
            if i >= 100:
                # add number of letters for "n hundred"
                count += ones_counts[i // 100] + 7

                if i % 100 != 0:
                    # add number of letters for "and" if number is not multiple
                    # of 100
                    count += 3

            if 0 < i % 100 < 20:
                # add number of letters for one, two, three, ..., nineteen
                # (could be combined with below if not for inconsistency in
                # teens)
                count += ones_counts[i % 100]
            else:
                # add number of letters for twenty, twenty one, ..., ninety
                # nine
                count += ones_counts[i % 10]
                count += tens_counts[(i % 100 - i % 10) // 10]
        else:
            count += ones_counts[i // 1_000] + 8
    return count


if __name__ == "__main__":
     print(solution(int(input().strip())))
