


"""simple docstring"""







import json
import os
from pathlib import Path
from shutil import copyfile
from typing import Any, Dict, List, Optional, Tuple, Union

import sentencepiece

from ...tokenization_utils import BatchEncoding, PreTrainedTokenizer
from ...utils import logging


a__       :							Optional[int]        =  logging.get_logger(__name__)

a__       :							Tuple        =  '''▁'''

a__       :							List[Any]        =  {
    '''vocab_file''': '''vocab.json''',
    '''spm_file''': '''sentencepiece.bpe.model''',
    '''tokenizer_config_file''': '''tokenizer_config.json''',
}

a__       :							List[str]        =  {
    '''vocab_file''': {
        '''facebook/m2m100_418M''': '''https://huggingface.co/facebook/m2m100_418M/resolve/main/vocab.json''',
        '''facebook/m2m100_1.2B''': '''https://huggingface.co/facebook/m2m100_1.2B/resolve/main/vocab.json''',
    },
    '''spm_file''': {
        '''facebook/m2m100_418M''': '''https://huggingface.co/facebook/m2m100_418M/resolve/main/sentencepiece.bpe.model''',
        '''facebook/m2m100_1.2B''': '''https://huggingface.co/facebook/m2m100_1.2B/resolve/main/sentencepiece.bpe.model''',
    },
    '''tokenizer_config_file''': {
        '''facebook/m2m100_418M''': '''https://huggingface.co/facebook/m2m100_418M/resolve/main/tokenizer_config.json''',
        '''facebook/m2m100_1.2B''': '''https://huggingface.co/facebook/m2m100_1.2B/resolve/main/tokenizer_config.json''',
    },
}

a__       :							Optional[int]        =  {
    '''facebook/m2m100_418M''': 1_0_2_4,
}

# fmt: off
a__       :							int        =  {
    '''m2m100''': ['''af''', '''am''', '''ar''', '''ast''', '''az''', '''ba''', '''be''', '''bg''', '''bn''', '''br''', '''bs''', '''ca''', '''ceb''', '''cs''', '''cy''', '''da''', '''de''', '''el''', '''en''', '''es''', '''et''', '''fa''', '''ff''', '''fi''', '''fr''', '''fy''', '''ga''', '''gd''', '''gl''', '''gu''', '''ha''', '''he''', '''hi''', '''hr''', '''ht''', '''hu''', '''hy''', '''id''', '''ig''', '''ilo''', '''is''', '''it''', '''ja''', '''jv''', '''ka''', '''kk''', '''km''', '''kn''', '''ko''', '''lb''', '''lg''', '''ln''', '''lo''', '''lt''', '''lv''', '''mg''', '''mk''', '''ml''', '''mn''', '''mr''', '''ms''', '''my''', '''ne''', '''nl''', '''no''', '''ns''', '''oc''', '''or''', '''pa''', '''pl''', '''ps''', '''pt''', '''ro''', '''ru''', '''sd''', '''si''', '''sk''', '''sl''', '''so''', '''sq''', '''sr''', '''ss''', '''su''', '''sv''', '''sw''', '''ta''', '''th''', '''tl''', '''tn''', '''tr''', '''uk''', '''ur''', '''uz''', '''vi''', '''wo''', '''xh''', '''yi''', '''yo''', '''zh''', '''zu'''],
    '''wmt21''': ['''en''', '''ha''', '''is''', '''ja''', '''cs''', '''ru''', '''zh''', '''de''']
}




class 				UpperCamelCase_			(				UpperCamelCase):

	"""simple docstring"""





	snake_case__       :						List[str]					      =    VOCAB_FILES_NAMES
	snake_case__       :						Optional[Any]					      =    PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
	snake_case__       :						Dict					      =    PRETRAINED_VOCAB_FILES_MAP
	snake_case__       :						Optional[int]					      =    ["input_ids", "attention_mask"]

	snake_case__       :						List[int]					      =    []
	snake_case__       :						List[int]					      =    []




	def __init__(				self    :       str    ,    UpperCAmelCase__    :       str    ,    UpperCAmelCase__    :       List[str]    ,    UpperCAmelCase__    :       Union[str, Any]=None    ,    UpperCAmelCase__    :       Dict=None    ,    UpperCAmelCase__    :       Any="<s>"    ,    UpperCAmelCase__    :       List[Any]="</s>"    ,    UpperCAmelCase__    :       Optional[Any]="</s>"    ,    UpperCAmelCase__    :       Dict="<pad>"    ,    UpperCAmelCase__    :       List[Any]="<unk>"    ,    UpperCAmelCase__    :       Optional[Any]="m2m100"    ,    UpperCAmelCase__    :       Optional[Dict[str, Any]] = None    ,    UpperCAmelCase__    :       int=8    ,    **UpperCAmelCase__    :       List[Any]    ,    ) ->			None:
						__SCREAMING_SNAKE_CASE		     =       {} if sp_model_kwargs is None else sp_model_kwargs

						__SCREAMING_SNAKE_CASE		     =       language_codes
						__SCREAMING_SNAKE_CASE		     =       FAIRSEQ_LANGUAGE_CODES[language_codes]
						__SCREAMING_SNAKE_CASE		     =       {lang_code: F"""__{lang_code}__""" for lang_code in fairseq_language_code}

						__SCREAMING_SNAKE_CASE		     =       kwargs.get("additional_special_tokens"    ,    []     )
						kwargs["additional_special_tokens"] += [
						    self.get_lang_token(UpperCAmelCase__     )
						    for lang_code in fairseq_language_code
						    if self.get_lang_token(UpperCAmelCase__     ) not in kwargs["additional_special_tokens"]
						]

						super().__init__(
						    src_lang=UpperCAmelCase__    ,    tgt_lang=UpperCAmelCase__    ,    bos_token=UpperCAmelCase__    ,    eos_token=UpperCAmelCase__    ,    sep_token=UpperCAmelCase__    ,    unk_token=UpperCAmelCase__    ,    pad_token=UpperCAmelCase__    ,    language_codes=UpperCAmelCase__    ,    sp_model_kwargs=self.sp_model_kwargs    ,    num_madeup_words=UpperCAmelCase__    ,    **UpperCAmelCase__    ,    )

						__SCREAMING_SNAKE_CASE		     =       vocab_file
						__SCREAMING_SNAKE_CASE		     =       load_json(UpperCAmelCase__     )
						__SCREAMING_SNAKE_CASE		     =       {v: k for k, v in self.encoder.items()}
						__SCREAMING_SNAKE_CASE		     =       spm_file
						__SCREAMING_SNAKE_CASE		     =       load_spm(UpperCAmelCase__    ,    self.sp_model_kwargs     )

						__SCREAMING_SNAKE_CASE		     =       len(self.encoder     )

						__SCREAMING_SNAKE_CASE		     =       {
						    self.get_lang_token(UpperCAmelCase__     ): self.encoder_size + i for i, lang_code in enumerate(UpperCAmelCase__     )
						}
						__SCREAMING_SNAKE_CASE		     =       {lang_code: self.encoder_size + i for i, lang_code in enumerate(UpperCAmelCase__     )}
						__SCREAMING_SNAKE_CASE		     =       {v: k for k, v in self.lang_token_to_id.items()}

						__SCREAMING_SNAKE_CASE		     =       src_lang if src_lang is not None else "en"
						__SCREAMING_SNAKE_CASE		     =       tgt_lang
						__SCREAMING_SNAKE_CASE		     =       self.get_lang_id(self._src_lang     )
						self.set_src_lang_special_tokens(self._src_lang     )

						__SCREAMING_SNAKE_CASE		     =       num_madeup_words




	@property
	def 						UpperCAmelCase_   (				self    :       Any     ) ->			int:
						return len(self.encoder     ) + len(self.lang_token_to_id     )




	@property
	def 						UpperCAmelCase_   (				self    :       Tuple     ) ->			str:
						return self._src_lang




	@src_lang.setter
	def 						UpperCAmelCase_   (				self    :       Optional[int]    ,    UpperCAmelCase__    :       str     ) ->			None:
						__SCREAMING_SNAKE_CASE		     =       new_src_lang
						self.set_src_lang_special_tokens(self._src_lang     )




	def 						UpperCAmelCase_   (				self    :       List[str]    ,    UpperCAmelCase__    :       str     ) ->			List[str]:
						return self.sp_model.encode(UpperCAmelCase__    ,    out_type=UpperCAmelCase__     )




	def 						UpperCAmelCase_   (				self    :       Union[str, Any]    ,    UpperCAmelCase__    :       Optional[Any]     ) ->			List[str]:
						if token in self.lang_token_to_id:
											return self.lang_token_to_id[token]
						return self.encoder.get(UpperCAmelCase__    ,    self.encoder[self.unk_token]     )




	def 						UpperCAmelCase_   (				self    :       List[Any]    ,    UpperCAmelCase__    :       int     ) ->			str:
						if index in self.id_to_lang_token:
											return self.id_to_lang_token[index]
						return self.decoder.get(UpperCAmelCase__    ,    self.unk_token     )




	def 						UpperCAmelCase_   (				self    :       Optional[int]    ,    UpperCAmelCase__    :       str     ) ->			Dict:
						__SCREAMING_SNAKE_CASE		     =       []
						__SCREAMING_SNAKE_CASE		     =       ""
						for token in tokens:
											# make sure that special tokens are not decoded using sentencepiece model
											if token in self.all_special_tokens:
																out_string += self.sp_model.decode(UpperCAmelCase__     ) + token
																__SCREAMING_SNAKE_CASE		     =       []
											else:
																current_sub_tokens.append(UpperCAmelCase__     )
						out_string += self.sp_model.decode(UpperCAmelCase__     )
						return out_string.strip()




	def 						UpperCAmelCase_   (				self    :       Dict    ,    UpperCAmelCase__    :       List[int]    ,    UpperCAmelCase__    :       Optional[List[int]] = None    ,    UpperCAmelCase__    :       bool = False     ) ->			List[int]:

						if already_has_special_tokens:
											return super().get_special_tokens_mask(
											    token_ids_a=UpperCAmelCase__    ,    token_ids_a=UpperCAmelCase__    ,    already_has_special_tokens=UpperCAmelCase__     )

						__SCREAMING_SNAKE_CASE		     =       [1] * len(self.prefix_tokens     )
						__SCREAMING_SNAKE_CASE		     =       [1] * len(self.suffix_tokens     )
						if token_ids_a is None:
											return prefix_ones + ([0] * len(UpperCAmelCase__     )) + suffix_ones
						return prefix_ones + ([0] * len(UpperCAmelCase__     )) + ([0] * len(UpperCAmelCase__     )) + suffix_ones




	def 						UpperCAmelCase_   (				self    :       Any    ,    UpperCAmelCase__    :       List[int]    ,    UpperCAmelCase__    :       Optional[List[int]] = None     ) ->			List[int]:
						if token_ids_a is None:
											return self.prefix_tokens + token_ids_a + self.suffix_tokens
						# We don't expect to process pairs, but leave the pair logic for API consistency
						return self.prefix_tokens + token_ids_a + token_ids_a + self.suffix_tokens




	def 						UpperCAmelCase_   (				self    :       int     ) ->			Dict:
						__SCREAMING_SNAKE_CASE		     =       {self.convert_ids_to_tokens(UpperCAmelCase__     ): i for i in range(self.vocab_size     )}
						vocab.update(self.added_tokens_encoder     )
						return vocab




	def __getstate__(				self    :       Any     ) ->			Dict:
						__SCREAMING_SNAKE_CASE		     =       self.__dict__.copy()
						__SCREAMING_SNAKE_CASE		     =       None
						return state




	def __setstate__(				self    :       Optional[Any]    ,    UpperCAmelCase__    :       Dict     ) ->			None:
						__SCREAMING_SNAKE_CASE		     =       d

						# for backward compatibility
						if not hasattr(self    ,    "sp_model_kwargs"     ):
											__SCREAMING_SNAKE_CASE		     =       {}

						__SCREAMING_SNAKE_CASE		     =       load_spm(self.spm_file    ,    self.sp_model_kwargs     )




	def 						UpperCAmelCase_   (				self    :       List[str]    ,    UpperCAmelCase__    :       str    ,    UpperCAmelCase__    :       Optional[str] = None     ) ->			Tuple[str]:
						__SCREAMING_SNAKE_CASE		     =       Path(UpperCAmelCase__     )
						if not save_dir.is_dir():
											raise OSError(F"""{save_directory} should be a directory"""     )
						__SCREAMING_SNAKE_CASE		     =       save_dir / (
						    (filename_prefix + "-" if filename_prefix else "") + self.vocab_files_names["vocab_file"]
						)
						__SCREAMING_SNAKE_CASE		     =       save_dir / (
						    (filename_prefix + "-" if filename_prefix else "") + self.vocab_files_names["spm_file"]
						)

						save_json(self.encoder    ,    UpperCAmelCase__     )

						if os.path.abspath(self.spm_file     ) != os.path.abspath(UpperCAmelCase__     ) and os.path.isfile(self.spm_file     ):
											copyfile(self.spm_file    ,    UpperCAmelCase__     )
						elif not os.path.isfile(self.spm_file     ):
											with open(UpperCAmelCase__    ,    "wb"     ) as fi:
																__SCREAMING_SNAKE_CASE		     =       self.sp_model.serialized_model_proto()
																fi.write(UpperCAmelCase__     )

						return (str(UpperCAmelCase__     ), str(UpperCAmelCase__     ))




	def 						UpperCAmelCase_   (				self    :       Optional[Any]    ,    UpperCAmelCase__    :       List[str]    ,    UpperCAmelCase__    :       str = "en"    ,    UpperCAmelCase__    :       Optional[List[str]] = None    ,    UpperCAmelCase__    :       str = "ro"    ,    **UpperCAmelCase__    :       Union[str, Any]    ,    ) ->			BatchEncoding:
						__SCREAMING_SNAKE_CASE		     =       src_lang
						__SCREAMING_SNAKE_CASE		     =       tgt_lang
						self.set_src_lang_special_tokens(self.src_lang     )
						return super().prepare_seqaseq_batch(UpperCAmelCase__    ,    UpperCAmelCase__    ,    **UpperCAmelCase__     )




	def 						UpperCAmelCase_   (				self    :       Optional[int]    ,    UpperCAmelCase__    :       str    ,    UpperCAmelCase__    :       Optional[str]    ,    UpperCAmelCase__    :       Optional[str]    ,    **UpperCAmelCase__    :       Dict     ) ->			List[str]:
						if src_lang is None or tgt_lang is None:
											raise ValueError("Translation requires a `src_lang` and a `tgt_lang` for this model"     )
						__SCREAMING_SNAKE_CASE		     =       src_lang
						__SCREAMING_SNAKE_CASE		     =       self(UpperCAmelCase__    ,    add_special_tokens=UpperCAmelCase__    ,    **UpperCAmelCase__     )
						__SCREAMING_SNAKE_CASE		     =       self.get_lang_id(UpperCAmelCase__     )
						__SCREAMING_SNAKE_CASE		     =       tgt_lang_id
						return inputs




	def 						UpperCAmelCase_   (				self    :       Any     ) ->			Union[str, Any]:
						self.set_src_lang_special_tokens(self.src_lang     )




	def 						UpperCAmelCase_   (				self    :       str     ) ->			Any:
						self.set_tgt_lang_special_tokens(self.tgt_lang     )




	def 						UpperCAmelCase_   (				self    :       Optional[int]    ,    UpperCAmelCase__    :       str     ) ->			None:
						__SCREAMING_SNAKE_CASE		     =       self.get_lang_token(UpperCAmelCase__     )
						__SCREAMING_SNAKE_CASE		     =       self.lang_token_to_id[lang_token]
						__SCREAMING_SNAKE_CASE		     =       [self.cur_lang_id]
						__SCREAMING_SNAKE_CASE		     =       [self.eos_token_id]




	def 						UpperCAmelCase_   (				self    :       Optional[Any]    ,    UpperCAmelCase__    :       str     ) ->			None:
						__SCREAMING_SNAKE_CASE		     =       self.get_lang_token(UpperCAmelCase__     )
						__SCREAMING_SNAKE_CASE		     =       self.lang_token_to_id[lang_token]
						__SCREAMING_SNAKE_CASE		     =       [self.cur_lang_id]
						__SCREAMING_SNAKE_CASE		     =       [self.eos_token_id]




	def 						UpperCAmelCase_   (				self    :       Tuple    ,    UpperCAmelCase__    :       str     ) ->			str:
						return self.lang_code_to_token[lang]




	def 						UpperCAmelCase_   (				self    :       str    ,    UpperCAmelCase__    :       str     ) ->			int:
						__SCREAMING_SNAKE_CASE		     =       self.get_lang_token(UpperCAmelCase__     )
						return self.lang_token_to_id[lang_token]




def      UpperCAmelCase__ (lowerCAmelCase_						,		lowerCAmelCase_     ):




					'''simple docstring'''


					__SCREAMING_SNAKE_CASE		     =       sentencepiece.SentencePieceProcessor(**lowerCAmelCase_     )
					spm.Load(str(lowerCAmelCase_     )     )
					return spm




def      UpperCAmelCase__ (lowerCAmelCase_     ):




					'''simple docstring'''


					with open(lowerCAmelCase_						,		"r"     ) as f:
										return json.load(lowerCAmelCase_     )




def      UpperCAmelCase__ (lowerCAmelCase_						,		lowerCAmelCase_     ):




					'''simple docstring'''


					with open(lowerCAmelCase_						,		"w"     ) as f:
										json.dump(lowerCAmelCase_						,		lowerCAmelCase_						,		indent=2     )




"""simple docstring"""







from __future__ import annotations




def      UpperCAmelCase__ (lowerCAmelCase_     ):




					'''simple docstring'''


					__SCREAMING_SNAKE_CASE		     =       str(lowerCAmelCase_     )
					return n == n[::-1]




def      UpperCAmelCase__ (lowerCAmelCase_ = 100_0000     ):




					'''simple docstring'''


					__SCREAMING_SNAKE_CASE		     =       0

					for i in range(1						,		lowerCAmelCase_     ):
										if is_palindrome(lowerCAmelCase_     ) and is_palindrome(bin(lowerCAmelCase_     ).split("b"     )[1]     ):
															total += i
					return total


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