
import math




def 		A_	(							snake_case							:				int	) ->      int:



						'''simple docstring'''

						return sum(int(snake_case	) for digit in str(snake_case	)	)




def 		A_	(							snake_case							:				int = 30	) ->      int:



						'''simple docstring'''

						__UpperCamelCase       					=     []
						for digit in range(2	, 100	):
												for power in range(2	, 100	):
																		__UpperCamelCase       					=     int(math.pow(snake_case	, snake_case	)	)
																		if digit == digit_sum(snake_case	):
																								digit_to_powers.append(snake_case	)

						digit_to_powers.sort()
						return digit_to_powers[n - 1]


if __name__ == "__main__":
				print(solution())






import json
import os
import re
import unicodedata
from typing import Dict, List, Optional, Tuple

from ...tokenization_utils import PreTrainedTokenizer
from ...utils import logging


lowercase__							:							Optional[Any]													=     logging.get_logger(__name__)

lowercase__							:							str													=     {
    "src_vocab_file": "vocab-src.json",
    "tgt_vocab_file": "vocab-tgt.json",
    "merges_file": "merges.txt",
}

lowercase__							:							int													=     {
    "src_vocab_file": {
        "stas/tiny-wmt19-en-de": "https://huggingface.co/stas/tiny-wmt19-en-de/resolve/main/vocab-src.json"
    },
    "tgt_vocab_file": {
        "stas/tiny-wmt19-en-de": "https://huggingface.co/stas/tiny-wmt19-en-de/resolve/main/vocab-tgt.json"
    },
    "merges_file": {"stas/tiny-wmt19-en-de": "https://huggingface.co/stas/tiny-wmt19-en-de/resolve/main/merges.txt"},
}

lowercase__							:							Any													=     {"stas/tiny-wmt19-en-de": 1_0_2_4}
lowercase__							:							List[str]													=     {
    "stas/tiny-wmt19-en-de": {
        "langs": ["en", "de"],
        "model_max_length": 1_0_2_4,
        "special_tokens_map_file": None,
        "full_tokenizer_file": None,
    }
}




def 		A_	(							snake_case							:				Union[str, Any]	) ->      Any:



						'''simple docstring'''

						__UpperCamelCase       					=     set()
						__UpperCamelCase       					=     word[0]
						for char in word[1:]:
												pairs.add((prev_char, char)	)
												__UpperCamelCase       					=     char
						return pairs




def 		A_	(							snake_case							:				Union[str, Any]	) ->      int:



						'''simple docstring'''

						__UpperCamelCase       					=     text.replace('''，'''	, ''','''	)
						__UpperCamelCase       					=     re.sub(r'''。\s*'''	, '''. '''	, snake_case	)
						__UpperCamelCase       					=     text.replace('''、'''	, ''','''	)
						__UpperCamelCase       					=     text.replace('''”'''	, '''"'''	)
						__UpperCamelCase       					=     text.replace('''“'''	, '''"'''	)
						__UpperCamelCase       					=     text.replace('''∶'''	, ''':'''	)
						__UpperCamelCase       					=     text.replace('''：'''	, ''':'''	)
						__UpperCamelCase       					=     text.replace('''？'''	, '''?'''	)
						__UpperCamelCase       					=     text.replace('''《'''	, '''"'''	)
						__UpperCamelCase       					=     text.replace('''》'''	, '''"'''	)
						__UpperCamelCase       					=     text.replace('''）'''	, ''')'''	)
						__UpperCamelCase       					=     text.replace('''！'''	, '''!'''	)
						__UpperCamelCase       					=     text.replace('''（'''	, '''('''	)
						__UpperCamelCase       					=     text.replace('''；'''	, ''';'''	)
						__UpperCamelCase       					=     text.replace('''１'''	, '''1'''	)
						__UpperCamelCase       					=     text.replace('''」'''	, '''"'''	)
						__UpperCamelCase       					=     text.replace('''「'''	, '''"'''	)
						__UpperCamelCase       					=     text.replace('''０'''	, '''0'''	)
						__UpperCamelCase       					=     text.replace('''３'''	, '''3'''	)
						__UpperCamelCase       					=     text.replace('''２'''	, '''2'''	)
						__UpperCamelCase       					=     text.replace('''５'''	, '''5'''	)
						__UpperCamelCase       					=     text.replace('''６'''	, '''6'''	)
						__UpperCamelCase       					=     text.replace('''９'''	, '''9'''	)
						__UpperCamelCase       					=     text.replace('''７'''	, '''7'''	)
						__UpperCamelCase       					=     text.replace('''８'''	, '''8'''	)
						__UpperCamelCase       					=     text.replace('''４'''	, '''4'''	)
						__UpperCamelCase       					=     re.sub(r'''．\s*'''	, '''. '''	, snake_case	)
						__UpperCamelCase       					=     text.replace('''～'''	, '''~'''	)
						__UpperCamelCase       					=     text.replace('''’'''	, '''\''''	)
						__UpperCamelCase       					=     text.replace('''…'''	, '''...'''	)
						__UpperCamelCase       					=     text.replace('''━'''	, '''-'''	)
						__UpperCamelCase       					=     text.replace('''〈'''	, '''<'''	)
						__UpperCamelCase       					=     text.replace('''〉'''	, '''>'''	)
						__UpperCamelCase       					=     text.replace('''【'''	, '''['''	)
						__UpperCamelCase       					=     text.replace('''】'''	, ''']'''	)
						__UpperCamelCase       					=     text.replace('''％'''	, '''%'''	)
						return text




def 		A_	(							snake_case							:				List[str]	) ->      Optional[Any]:



						'''simple docstring'''

						__UpperCamelCase       					=     []
						for char in text:
												__UpperCamelCase       					=     unicodedata.category(snake_case	)
												if cat.startswith('''C'''	):
																		continue
												output.append(snake_case	)
						return "".join(snake_case	)






class     SCREAMING_SNAKE_CASE__      (							SCREAMING_SNAKE_CASE_      ):

							"""simple docstring"""






							_snake_case       						=					VOCAB_FILES_NAMES
							_snake_case       						=					PRETRAINED_VOCAB_FILES_MAP
							_snake_case       						=					PRETRAINED_INIT_CONFIGURATION
							_snake_case       						=					PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
							_snake_case       						=					['input_ids', 'attention_mask']



							def __init__(					self       ,		SCREAMING_SNAKE_CASE_=None       ,		SCREAMING_SNAKE_CASE_=None       ,		SCREAMING_SNAKE_CASE_=None       ,		SCREAMING_SNAKE_CASE_=None       ,		SCREAMING_SNAKE_CASE_=False       ,		SCREAMING_SNAKE_CASE_="<unk>"       ,		SCREAMING_SNAKE_CASE_="<s>"       ,		SCREAMING_SNAKE_CASE_="</s>"       ,		SCREAMING_SNAKE_CASE_="<pad>"       ,		**SCREAMING_SNAKE_CASE_       ,		)->				str:





													'''simple docstring'''






													super().__init__(
													    langs=SCREAMING_SNAKE_CASE_       ,		src_vocab_file=SCREAMING_SNAKE_CASE_       ,		tgt_vocab_file=SCREAMING_SNAKE_CASE_       ,		merges_file=SCREAMING_SNAKE_CASE_       ,		do_lower_case=SCREAMING_SNAKE_CASE_       ,		unk_token=SCREAMING_SNAKE_CASE_       ,		bos_token=SCREAMING_SNAKE_CASE_       ,		sep_token=SCREAMING_SNAKE_CASE_       ,		pad_token=SCREAMING_SNAKE_CASE_       ,		**SCREAMING_SNAKE_CASE_       ,		)

													try:
																			import sacremoses
													except ImportError:
																			raise ImportError(
																			    '''You need to install sacremoses to use XLMTokenizer. '''
																			    '''See https://pypi.org/project/sacremoses/ for installation.'''     )

													__UpperCamelCase       					=     sacremoses

													__UpperCamelCase       					=     src_vocab_file
													__UpperCamelCase       					=     tgt_vocab_file
													__UpperCamelCase       					=     merges_file
													__UpperCamelCase       					=     do_lower_case

													# cache of sm.MosesPunctNormalizer instance
													__UpperCamelCase       					=     {}
													# cache of sm.MosesTokenizer instance
													__UpperCamelCase       					=     {}
													__UpperCamelCase       					=     {}

													if langs and len(SCREAMING_SNAKE_CASE_     ) == 2:
																			__UpperCamelCase					,							__UpperCamelCase       					=     langs
													else:
																			raise ValueError(
																			    F"arg `langs` needs to be a list of 2 langs, e.g. ['en', 'ru'], but got {langs}. "
																			    '''Usually that means that tokenizer can\'t find a mapping for the given model path '''
																			    '''in PRETRAINED_VOCAB_FILES_MAP, and other maps of this tokenizer.'''     )

													with open(SCREAMING_SNAKE_CASE_       ,		encoding='''utf-8'''     ) as src_vocab_handle:
																			__UpperCamelCase       					=     json.load(SCREAMING_SNAKE_CASE_     )
													with open(SCREAMING_SNAKE_CASE_       ,		encoding='''utf-8'''     ) as tgt_vocab_handle:
																			__UpperCamelCase       					=     json.load(SCREAMING_SNAKE_CASE_     )
																			__UpperCamelCase       					=     {v: k for k, v in tgt_vocab.items()}
													with open(SCREAMING_SNAKE_CASE_       ,		encoding='''utf-8'''     ) as merges_handle:
																			__UpperCamelCase       					=     merges_handle.read().split('''\n'''     )[:-1]
													__UpperCamelCase       					=     [tuple(merge.split()[:2]     ) for merge in merges]
													__UpperCamelCase       					=     dict(zip(SCREAMING_SNAKE_CASE_       ,		range(len(SCREAMING_SNAKE_CASE_     )     )     )     )
													__UpperCamelCase       					=     {}



							def       A__						(					self     )->				Dict[str, int]:





													'''simple docstring'''






													return self.get_src_vocab()



							@property
							def       A__						(					self     )->				int:





													'''simple docstring'''






													return self.src_vocab_size



							def       A__						(					self       ,		SCREAMING_SNAKE_CASE_       ,		SCREAMING_SNAKE_CASE_     )->				int:





													'''simple docstring'''






													if lang not in self.cache_moses_punct_normalizer:
																			__UpperCamelCase       					=     self.sm.MosesPunctNormalizer(lang=SCREAMING_SNAKE_CASE_     )
																			__UpperCamelCase       					=     punct_normalizer
													return self.cache_moses_punct_normalizer[lang].normalize(SCREAMING_SNAKE_CASE_     )



							def       A__						(					self       ,		SCREAMING_SNAKE_CASE_       ,		SCREAMING_SNAKE_CASE_     )->				Tuple:





													'''simple docstring'''






													if lang not in self.cache_moses_tokenizer:
																			__UpperCamelCase       					=     self.sm.MosesTokenizer(lang=SCREAMING_SNAKE_CASE_     )
																			__UpperCamelCase       					=     moses_tokenizer
													return self.cache_moses_tokenizer[lang].tokenize(
													    SCREAMING_SNAKE_CASE_       ,		aggressive_dash_splits=SCREAMING_SNAKE_CASE_       ,		return_str=SCREAMING_SNAKE_CASE_       ,		escape=SCREAMING_SNAKE_CASE_     )



							def       A__						(					self       ,		SCREAMING_SNAKE_CASE_       ,		SCREAMING_SNAKE_CASE_     )->				Tuple:





													'''simple docstring'''






													if lang not in self.cache_moses_detokenizer:
																			__UpperCamelCase       					=     self.sm.MosesDetokenizer(lang=SCREAMING_SNAKE_CASE_     )
																			__UpperCamelCase       					=     moses_detokenizer
													return self.cache_moses_detokenizer[lang].detokenize(SCREAMING_SNAKE_CASE_     )



							def       A__						(					self       ,		SCREAMING_SNAKE_CASE_       ,		SCREAMING_SNAKE_CASE_     )->				List[Any]:





													'''simple docstring'''






													__UpperCamelCase       					=     replace_unicode_punct(SCREAMING_SNAKE_CASE_     )
													__UpperCamelCase       					=     self.moses_punct_norm(SCREAMING_SNAKE_CASE_       ,		SCREAMING_SNAKE_CASE_     )
													__UpperCamelCase       					=     remove_non_printing_char(SCREAMING_SNAKE_CASE_     )
													return text



							@property
							def       A__						(					self     )->				List[str]:





													'''simple docstring'''






													return len(self.encoder     )



							@property
							def       A__						(					self     )->				Any:





													'''simple docstring'''






													return len(self.decoder     )



							def       A__						(					self     )->				int:





													'''simple docstring'''






													return dict(self.encoder       ,		**self.added_tokens_encoder     )



							def       A__						(					self     )->				Any:





													'''simple docstring'''






													return dict(self.decoder       ,		**self.added_tokens_decoder     )



							def       A__						(					self       ,		SCREAMING_SNAKE_CASE_     )->				Optional[Any]:





													'''simple docstring'''






													__UpperCamelCase       					=     tuple(token[:-1]     ) + (token[-1] + '''</w>''',)
													if token in self.cache:
																			return self.cache[token]
													__UpperCamelCase       					=     get_pairs(SCREAMING_SNAKE_CASE_     )

													if not pairs:
																			return token + "</w>"

													while True:
																			__UpperCamelCase       					=     min(SCREAMING_SNAKE_CASE_       ,		key=lambda SCREAMING_SNAKE_CASE_     : self.bpe_ranks.get(SCREAMING_SNAKE_CASE_       ,		float('''inf'''     )     )     )
																			if bigram not in self.bpe_ranks:
																									break
																			__UpperCamelCase					,							__UpperCamelCase       					=     bigram
																			__UpperCamelCase       					=     []
																			__UpperCamelCase       					=     0
																			while i < len(SCREAMING_SNAKE_CASE_     ):
																									try:
																															__UpperCamelCase       					=     word.index(SCREAMING_SNAKE_CASE_       ,		SCREAMING_SNAKE_CASE_     )
																									except ValueError:
																															new_word.extend(word[i:]     )
																															break
																									else:
																															new_word.extend(word[i:j]     )
																															__UpperCamelCase       					=     j

																									if word[i] == first and i < len(SCREAMING_SNAKE_CASE_     ) - 1 and word[i + 1] == second:
																															new_word.append(first + second     )
																															i += 2
																									else:
																															new_word.append(word[i]     )
																															i += 1
																			__UpperCamelCase       					=     tuple(SCREAMING_SNAKE_CASE_     )
																			__UpperCamelCase       					=     new_word
																			if len(SCREAMING_SNAKE_CASE_     ) == 1:
																									break
																			else:
																									__UpperCamelCase       					=     get_pairs(SCREAMING_SNAKE_CASE_     )
													__UpperCamelCase       					=     ''' '''.join(SCREAMING_SNAKE_CASE_     )
													if word == "\n  </w>":
																			__UpperCamelCase       					=     '''\n</w>'''
													__UpperCamelCase       					=     word
													return word



							def       A__						(					self       ,		SCREAMING_SNAKE_CASE_       ,		SCREAMING_SNAKE_CASE_="en"       ,		SCREAMING_SNAKE_CASE_=False     )->				List[Any]:





													'''simple docstring'''






													__UpperCamelCase       					=     self.src_lang

													if self.do_lower_case:
																			__UpperCamelCase       					=     text.lower()

													if bypass_tokenizer:
																			__UpperCamelCase       					=     text.split()
													else:
																			__UpperCamelCase       					=     self.moses_pipeline(SCREAMING_SNAKE_CASE_       ,		lang=SCREAMING_SNAKE_CASE_     )
																			__UpperCamelCase       					=     self.moses_tokenize(SCREAMING_SNAKE_CASE_       ,		lang=SCREAMING_SNAKE_CASE_     )

													__UpperCamelCase       					=     []
													for token in text:
																			if token:
																									split_tokens.extend(list(self.bpe(SCREAMING_SNAKE_CASE_     ).split(''' '''     )     )     )

													return split_tokens



							def       A__						(					self       ,		SCREAMING_SNAKE_CASE_     )->				Any:





													'''simple docstring'''






													return self.encoder.get(SCREAMING_SNAKE_CASE_       ,		self.encoder.get(self.unk_token     )     )



							def       A__						(					self       ,		SCREAMING_SNAKE_CASE_     )->				Tuple:





													'''simple docstring'''






													return self.decoder.get(SCREAMING_SNAKE_CASE_       ,		self.unk_token     )



							def       A__						(					self       ,		SCREAMING_SNAKE_CASE_     )->				List[Any]:





													'''simple docstring'''






													__UpperCamelCase       					=     [t.replace(''' '''       ,		''''''     ).replace('''</w>'''       ,		''' '''     ) for t in tokens]
													__UpperCamelCase       					=     ''''''.join(SCREAMING_SNAKE_CASE_     ).split()
													# detokenize
													__UpperCamelCase       					=     self.moses_detokenize(SCREAMING_SNAKE_CASE_       ,		self.tgt_lang     )
													return text



							def       A__						(					self       ,		SCREAMING_SNAKE_CASE_       ,		SCREAMING_SNAKE_CASE_ = None     )->				List[int]:





													'''simple docstring'''






													__UpperCamelCase       					=     [self.sep_token_id]

													# no bos used in fairseq
													if token_ids_a is None:
																			return token_ids_a + sep
													return token_ids_a + sep + token_ids_a + sep



							def       A__						(					self       ,		SCREAMING_SNAKE_CASE_       ,		SCREAMING_SNAKE_CASE_ = None       ,		SCREAMING_SNAKE_CASE_ = False     )->				List[int]:





													'''simple docstring'''






													if already_has_special_tokens:
																			return super().get_special_tokens_mask(
																			    token_ids_a=SCREAMING_SNAKE_CASE_       ,		token_ids_a=SCREAMING_SNAKE_CASE_       ,		already_has_special_tokens=SCREAMING_SNAKE_CASE_     )
													# no bos used in fairseq
													if token_ids_a is not None:
																			return ([0] * len(SCREAMING_SNAKE_CASE_     )) + [1] + ([0] * len(SCREAMING_SNAKE_CASE_     )) + [1]
													return ([0] * len(SCREAMING_SNAKE_CASE_     )) + [1]



							def       A__						(					self       ,		SCREAMING_SNAKE_CASE_       ,		SCREAMING_SNAKE_CASE_ = None     )->				List[int]:





													'''simple docstring'''






													__UpperCamelCase       					=     [self.sep_token_id]

													# no bos used in fairseq
													if token_ids_a is None:
																			return len(token_ids_a + sep     ) * [0]
													return len(token_ids_a + sep     ) * [0] + len(token_ids_a + sep     ) * [1]



							def       A__						(					self       ,		SCREAMING_SNAKE_CASE_       ,		SCREAMING_SNAKE_CASE_ = None     )->				Tuple[str]:





													'''simple docstring'''






													if not os.path.isdir(SCREAMING_SNAKE_CASE_     ):
																			logger.error(F"Vocabulary path ({save_directory}) should be a directory"     )
																			return

													__UpperCamelCase       					=     os.path.join(
													    SCREAMING_SNAKE_CASE_       ,		(filename_prefix + '''-''' if filename_prefix else '''''') + VOCAB_FILES_NAMES['''src_vocab_file''']     )
													__UpperCamelCase       					=     os.path.join(
													    SCREAMING_SNAKE_CASE_       ,		(filename_prefix + '''-''' if filename_prefix else '''''') + VOCAB_FILES_NAMES['''tgt_vocab_file''']     )
													__UpperCamelCase       					=     os.path.join(
													    SCREAMING_SNAKE_CASE_       ,		(filename_prefix + '''-''' if filename_prefix else '''''') + VOCAB_FILES_NAMES['''merges_file''']     )

													with open(SCREAMING_SNAKE_CASE_       ,		'''w'''       ,		encoding='''utf-8'''     ) as f:
																			f.write(json.dumps(self.encoder       ,		indent=2       ,		sort_keys=SCREAMING_SNAKE_CASE_       ,		ensure_ascii=SCREAMING_SNAKE_CASE_     ) + '''\n'''     )

													with open(SCREAMING_SNAKE_CASE_       ,		'''w'''       ,		encoding='''utf-8'''     ) as f:
																			__UpperCamelCase       					=     {v: k for k, v in self.decoder.items()}
																			f.write(json.dumps(SCREAMING_SNAKE_CASE_       ,		indent=2       ,		sort_keys=SCREAMING_SNAKE_CASE_       ,		ensure_ascii=SCREAMING_SNAKE_CASE_     ) + '''\n'''     )

													__UpperCamelCase       					=     0
													with open(SCREAMING_SNAKE_CASE_       ,		'''w'''       ,		encoding='''utf-8'''     ) as writer:
																			for bpe_tokens, token_index in sorted(self.bpe_ranks.items()       ,		key=lambda SCREAMING_SNAKE_CASE_     : kv[1]     ):
																									if index != token_index:
																															logger.warning(
																															    F"Saving vocabulary to {merges_file}: BPE merge indices are not consecutive."
																															    ''' Please check that the tokenizer is not corrupted!'''     )
																															__UpperCamelCase       					=     token_index
																									writer.write(''' '''.join(SCREAMING_SNAKE_CASE_     ) + '''\n'''     )
																									index += 1

													return src_vocab_file, tgt_vocab_file, merges_file



							def __getstate__(					self     )->				str:





													'''simple docstring'''






													__UpperCamelCase       					=     self.__dict__.copy()
													__UpperCamelCase       					=     None
													return state



							def __setstate__(					self       ,		SCREAMING_SNAKE_CASE_     )->				List[Any]:





													'''simple docstring'''






													__UpperCamelCase       					=     d

													try:
																			import sacremoses
													except ImportError:
																			raise ImportError(
																			    '''You need to install sacremoses to use XLMTokenizer. '''
																			    '''See https://pypi.org/project/sacremoses/ for installation.'''     )

													__UpperCamelCase       					=     sacremoses




