



'''simple docstring'''

def     __UpperCamelCase					(				_lowercase,					_lowercase       )			->      list[tuple[int, int, int]]:
	_lowercase       :							Optional[Any]  	=		sorted(_lowercase,					key=lambda _lowercase       : edge[2]       )

	_lowercase       :							int  	=		list(range(_lowercase       )       )

	def find_parent(_lowercase       ):
		if i != parent[i]:
			_lowercase       :							Any  	=		find_parent(parent[i]       )
		return parent[i]

	_lowercase       :							Optional[int]  	=		0
	_lowercase       :							List[str]  	=		[]

	for edge in edges:
		_lowercase       :							Tuple  	=		find_parent(edge[0]       )
		_lowercase       :							Optional[int]  	=		find_parent(edge[1]       )
		if parent_a != parent_b:
			minimum_spanning_tree_cost += edge[2]
			minimum_spanning_tree.append(_lowercase       )
			_lowercase       :							Tuple  	=		parent_b

	return minimum_spanning_tree


if __name__ == "__main__":  # pragma: no cover
		_A    ,      _A					:     Any      =list(map(int, input().strip().split()))
		_A					:     Dict      =[]

		for _ in range(num_edges):
				_A    ,      _A    ,      _A					:     int      =(int(x) for x in input().strip().split())
				edges.append((nodea, nodea, cost))

		kruskal(num_nodes, edges)





'''simple docstring'''

def     __UpperCamelCase					(				_lowercase = 1000       )			->      int:
	_lowercase       :							Optional[int]  	=		[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)
	_lowercase       :							List[Any]  	=		[0, 0, 6, 6, 5, 5, 5, 7, 6, 6]

	_lowercase       :							Any  	=		0

	for i in range(1,					n + 1       ):
		if i < 1000:
			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 // 1000] + 8
	return count


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