
'''simple docstring'''







import os
import string
import sys


_lowercase :  str    							=       1 << 8

_lowercase :  Tuple    							=       {
    "tab": ord("\t"),
    "newline": ord("\r"),
    "esc": 2_7,
    "up": 6_5 + ARROW_KEY_FLAG,
    "down": 6_6 + ARROW_KEY_FLAG,
    "right": 6_7 + ARROW_KEY_FLAG,
    "left": 6_8 + ARROW_KEY_FLAG,
    "mod_int": 9_1,
    "undefined": sys.maxsize,
    "interrupt": 3,
    "insert": 5_0,
    "delete": 5_1,
    "pg_up": 5_3,
    "pg_down": 5_4,
}

_lowercase :  List[str]    							=       KEYMAP["up"]
_lowercase :  Any    							=       KEYMAP["left"]

if sys.platform == "win32":
							_lowercase :  str    							=       []
							_lowercase :  List[str]    							=       {
							    B"\xe0H": KEYMAP["up"] - ARROW_KEY_FLAG,
							    B"\x00H": KEYMAP["up"] - ARROW_KEY_FLAG,
							    B"\xe0P": KEYMAP["down"] - ARROW_KEY_FLAG,
							    B"\x00P": KEYMAP["down"] - ARROW_KEY_FLAG,
							    B"\xe0M": KEYMAP["right"] - ARROW_KEY_FLAG,
							    B"\x00M": KEYMAP["right"] - ARROW_KEY_FLAG,
							    B"\xe0K": KEYMAP["left"] - ARROW_KEY_FLAG,
							    B"\x00K": KEYMAP["left"] - ARROW_KEY_FLAG,
							}

for i in range(1_0):
							_lowercase :  Any    							=       ord(str(i))
def 					snake_case_		(				):



						"""simple docstring"""





						if os.name == "nt":
												import msvcrt

												lowercase_	:     Dict													=       '''mbcs'''
												# Flush the keyboard buffer
												while msvcrt.kbhit():
																		msvcrt.getch()
												if len(__SCREAMING_SNAKE_CASE							) == 0:
																		# Read the keystroke
																		lowercase_	:     Optional[Any]													=       msvcrt.getch()

																		# If it is a prefix char, get second part
																		if ch in (b"\x00", b"\xe0"):
																								lowercase_	:     Any													=       ch + msvcrt.getch()
																								# Translate actual Win chars to bullet char types
																								try:
																														lowercase_	:     Tuple													=       chr(WIN_KEYMAP[cha]							)
																														WIN_CH_BUFFER.append(chr(KEYMAP['''mod_int''']							)							)
																														WIN_CH_BUFFER.append(__SCREAMING_SNAKE_CASE							)
																														if ord(__SCREAMING_SNAKE_CASE							) in (
																														    KEYMAP["insert"] - 1 << 9,
																														    KEYMAP["delete"] - 1 << 9,
																														    KEYMAP["pg_up"] - 1 << 9,
																														    KEYMAP["pg_down"] - 1 << 9,
																														):
																																				WIN_CH_BUFFER.append(chr(126							)							)
																														lowercase_	:     Dict													=       chr(KEYMAP['''esc''']							)
																								except KeyError:
																														lowercase_	:     Dict													=       cha[1]
																		else:
																								lowercase_	:     List[Any]													=       ch.decode(__SCREAMING_SNAKE_CASE							)
												else:
																		lowercase_	:     Any													=       WIN_CH_BUFFER.pop(0							)
						elif os.name == "posix":
												import termios
												import tty

												lowercase_	:     Dict													=       sys.stdin.fileno()
												lowercase_	:     List[Any]													=       termios.tcgetattr(__SCREAMING_SNAKE_CASE							)
												try:
																		tty.setraw(__SCREAMING_SNAKE_CASE							)
																		lowercase_	:     Tuple													=       sys.stdin.read(1							)
												finally:
																		termios.tcsetattr(__SCREAMING_SNAKE_CASE      ,      termios.TCSADRAIN      ,      __SCREAMING_SNAKE_CASE							)
						return ch




def 					snake_case_		(				):



						"""simple docstring"""





						lowercase_	:     Optional[int]													=       get_raw_chars()
						if ord(__SCREAMING_SNAKE_CASE							) in [KEYMAP["interrupt"], KEYMAP["newline"]]:
												return char

						elif ord(__SCREAMING_SNAKE_CASE							) == KEYMAP["esc"]:
												lowercase_	:     str													=       get_raw_chars()
												if ord(__SCREAMING_SNAKE_CASE							) == KEYMAP["mod_int"]:
																		lowercase_	:     Dict													=       get_raw_chars()
																		if ord(__SCREAMING_SNAKE_CASE							) >= KEYMAP["arrow_begin"] - ARROW_KEY_FLAG and ord(__SCREAMING_SNAKE_CASE							) <= KEYMAP["arrow_end"] - ARROW_KEY_FLAG:
																								return chr(ord(__SCREAMING_SNAKE_CASE							) + ARROW_KEY_FLAG							)
																		else:
																								return KEYMAP["undefined"]
												else:
																		return get_raw_chars()

						else:
												if char in string.printable:
																		return char
												else:
																		return KEYMAP["undefined"]





'''simple docstring'''







_lowercase :  int    							=       [sum(int(c, 1_0) ** 2 for c in i.__str__()) for i in range(1_0_0_0_0_0)]
def 					snake_case_		(				__SCREAMING_SNAKE_CASE					: int							):



						"""simple docstring"""





						lowercase_	:     Optional[int]													=       0
						while number:
												# Increased Speed Slightly by checking every 5 digits together.
												sum_of_digits_squared += DIGITS_SQUARED[number % 100000]
												number //= 100000

						return sum_of_digits_squared


# There are 2 Chains made,
# One ends with 89 with the chain member 58 being the one which when declared first,
# there will be the least number of iterations for all the members to be checked.

# The other one ends with 1 and has only one element 1.

# So 58 and 1 are chosen to be declared at the starting.

# Changed dictionary to an array to quicken the solution
_lowercase :  list[bool | None]    							=       [None] * 1_0_0_0_0_0_0_0
_lowercase :  List[str]    							=       True
_lowercase :  Optional[int]    							=       False
def 					snake_case_		(				__SCREAMING_SNAKE_CASE					: int							):



						"""simple docstring"""





						if CHAINS[number - 1] is not None:
												return CHAINS[number - 1]  # type: ignore

						lowercase_	:     Tuple													=       chain(next_number(__SCREAMING_SNAKE_CASE							)							)
						lowercase_	:     Union[str, Any]													=       number_chain

						while number < 10000000:
												lowercase_	:     int													=       number_chain
												number *= 10

						return number_chain
def 					snake_case_		(				__SCREAMING_SNAKE_CASE					: int = 10000000							):



						"""simple docstring"""





						for i in range(1      ,      __SCREAMING_SNAKE_CASE							):
												if CHAINS[i] is None:
																		chain(i + 1							)

						return CHAINS[:number].count(__SCREAMING_SNAKE_CASE							)


if __name__ == "__main__":
							import doctest

							doctest.testmod()
							print(f"""{solution() = }""")



