


import os
import sys

from . import rsa_key_generator as rkg

__lowerCamelCase   	=  128
__lowerCamelCase   	=  256



def 			_a      (    __UpperCamelCase	,	__UpperCamelCase = DEFAULT_BLOCK_SIZE			):
     a_     :  Tuple				      =     message.encode("""ascii"""			)

     a_     :  Dict				      =     []
     for block_start in range(0	,	len(__UpperCamelCase			)	,	__UpperCamelCase			):
          a_     :  int				      =     0
          for i in range(__UpperCamelCase	,	min(block_start + block_size	,	len(__UpperCamelCase			)			)			):
               block_int += message_bytes[i] * (BYTE_SIZE ** (i % block_size))
          block_ints.append(__UpperCamelCase			)
     return block_ints



def 			_a      (    __UpperCamelCase	,	__UpperCamelCase	,	__UpperCamelCase = DEFAULT_BLOCK_SIZE			):
     a_     :  list[str]				      =     []
     for block_int in block_ints:
          a_     :  list[str]				      =     []
          for i in range(block_size - 1	,	-1	,	-1			):
               if len(__UpperCamelCase			) + i < message_length:
                    a_     :  List[Any]				      =     block_int // (BYTE_SIZE**i)
                    a_     :  Optional[Any]				      =     block_int % (BYTE_SIZE**i)
                    block_message.insert(0	,	chr(__UpperCamelCase			)			)
          message.extend(__UpperCamelCase			)
     return "".join(__UpperCamelCase			)



def 			_a      (    __UpperCamelCase	,	__UpperCamelCase	,	__UpperCamelCase = DEFAULT_BLOCK_SIZE			):
     a_     :  str				      =     []
     a_      ,      a_     :  Tuple				      =     key

     for block in get_blocks_from_text(__UpperCamelCase	,	__UpperCamelCase			):
          encrypted_blocks.append(pow(__UpperCamelCase	,	__UpperCamelCase	,	__UpperCamelCase			)			)
     return encrypted_blocks



def 			_a      (    __UpperCamelCase	,	__UpperCamelCase	,	__UpperCamelCase	,	__UpperCamelCase = DEFAULT_BLOCK_SIZE	,	):
     a_     :  Optional[int]				      =     []
     a_      ,      a_     :  Any				      =     key
     for block in encrypted_blocks:
          decrypted_blocks.append(pow(__UpperCamelCase	,	__UpperCamelCase	,	__UpperCamelCase			)			)
     return get_text_from_blocks(__UpperCamelCase	,	__UpperCamelCase	,	__UpperCamelCase			)



def 			_a      (    __UpperCamelCase			):
     with open(__UpperCamelCase			) as fo:
          a_     :  int				      =     fo.read()
     a_      ,      a_      ,      a_     :  Any				      =     content.split(""","""			)
     return (int(__UpperCamelCase			), int(__UpperCamelCase			), int(__UpperCamelCase			))



def 			_a      (    __UpperCamelCase	,	__UpperCamelCase	,	__UpperCamelCase	,	__UpperCamelCase = DEFAULT_BLOCK_SIZE	,	):
     a_      ,      a_      ,      a_     :  List[Any]				      =     read_key_file(__UpperCamelCase			)
     if key_size < block_size * 8:
          sys.exit(
              """ERROR: Block size is {} bits and key size is {} bits. The RSA cipher """
              """requires the block size to be equal to or greater than the key size. """
              """Either decrease the block size or use different keys.""".format(
                  block_size * 8	,	__UpperCamelCase			)			)

     a_     :  int				      =     [str(__UpperCamelCase			) for i in encrypt_message(__UpperCamelCase	,	(n, e)	,	__UpperCamelCase			)]

     a_     :  Optional[Any]				      =     """,""".join(__UpperCamelCase			)
     a_     :  str				      =     F'''{len(__UpperCamelCase			)}_{block_size}_{encrypted_content}'''
     with open(__UpperCamelCase	,	"""w"""			) as fo:
          fo.write(__UpperCamelCase			)
     return encrypted_content



def 			_a      (    __UpperCamelCase	,	__UpperCamelCase			):
     a_      ,      a_      ,      a_     :  str				      =     read_key_file(__UpperCamelCase			)
     with open(__UpperCamelCase			) as fo:
          a_     :  int				      =     fo.read()
     a_      ,      a_      ,      a_     :  Optional[int]				      =     content.split("""_"""			)
     a_     :  Any				      =     int(__UpperCamelCase			)
     a_     :  str				      =     int(__UpperCamelCase			)

     if key_size < block_size * 8:
          sys.exit(
              """ERROR: Block size is {} bits and key size is {} bits. The RSA cipher """
              """requires the block size to be equal to or greater than the key size. """
              """Did you specify the correct key file and encrypted file?""".format(
                  block_size * 8	,	__UpperCamelCase			)			)

     a_     :  Tuple				      =     []
     for block in encrypted_message.split(""","""			):
          encrypted_blocks.append(int(__UpperCamelCase			)			)

     return decrypt_message(__UpperCamelCase	,	__UpperCamelCase	,	(n, d)	,	__UpperCamelCase			)



def 			_a      (    ):
     a_     :  Any				      =     """encrypted_file.txt"""
     a_     :  Union[str, Any]				      =     input(r"""Encrypt\Decrypt [e\d]: """			)

     if response.lower().startswith("""e"""			):
          a_     :  Any				      =     """encrypt"""
     elif response.lower().startswith("""d"""			):
          a_     :  Optional[Any]				      =     """decrypt"""

     if mode == "encrypt":
          if not os.path.exists("""rsa_pubkey.txt"""			):
               rkg.make_key_files("""rsa"""	,	1_0_2_4			)

          a_     :  Dict				      =     input("""\nEnter message: """			)
          a_     :  Optional[Any]				      =     """rsa_pubkey.txt"""
          print(F'''Encrypting and writing to {filename}...'''			)
          a_     :  Optional[Any]				      =     encrypt_and_write_to_file(__UpperCamelCase	,	__UpperCamelCase	,	__UpperCamelCase			)

          print("""\nEncrypted text:"""			)
          print(__UpperCamelCase			)

     elif mode == "decrypt":
          a_     :  Union[str, Any]				      =     """rsa_privkey.txt"""
          print(F'''Reading from {filename} and decrypting...'''			)
          a_     :  List[Any]				      =     read_from_file_and_decrypt(__UpperCamelCase	,	__UpperCamelCase			)
          print("""writing decryption to rsa_decryption.txt..."""			)
          with open("""rsa_decryption.txt"""	,	"""w"""			) as dec:
               dec.write(__UpperCamelCase			)

          print("""\nDecryption:"""			)
          print(__UpperCamelCase			)


if __name__ == "__main__":
       main()








'''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())))
