'''simple docstring'''






import json
from typing import List, Optional, Tuple

from tokenizers import normalizers
from tokenizers.pre_tokenizers import BertPreTokenizer, PreTokenizer

from ...tokenization_utils_fast import PreTrainedTokenizerFast
from ...utils import logging
from .tokenization_roformer import RoFormerTokenizer
from .tokenization_utils import JiebaPreTokenizer


_UpperCAmelCase    :     List[Any]         =       logging.get_logger(__name__)

_UpperCAmelCase    :     Dict         =       {'''vocab_file''': '''vocab.txt''', '''tokenizer_file''': '''tokenizer.json'''}

_UpperCAmelCase    :     List[str]         =       {
    '''vocab_file''': {
        '''junnyu/roformer_chinese_small''': '''https://huggingface.co/junnyu/roformer_chinese_small/resolve/main/vocab.txt''',
        '''junnyu/roformer_chinese_base''': '''https://huggingface.co/junnyu/roformer_chinese_base/resolve/main/vocab.txt''',
        '''junnyu/roformer_chinese_char_small''': (
            '''https://huggingface.co/junnyu/roformer_chinese_char_small/resolve/main/vocab.txt'''
        ),
        '''junnyu/roformer_chinese_char_base''': (
            '''https://huggingface.co/junnyu/roformer_chinese_char_base/resolve/main/vocab.txt'''
        ),
        '''junnyu/roformer_small_discriminator''': (
            '''https://huggingface.co/junnyu/roformer_small_discriminator/resolve/main/vocab.txt'''
        ),
        '''junnyu/roformer_small_generator''': (
            '''https://huggingface.co/junnyu/roformer_small_generator/resolve/main/vocab.txt'''
        ),
    }
}

_UpperCAmelCase    :     Optional[int]         =       {
    '''junnyu/roformer_chinese_small''': 15_36,
    '''junnyu/roformer_chinese_base''': 15_36,
    '''junnyu/roformer_chinese_char_small''': 5_12,
    '''junnyu/roformer_chinese_char_base''': 5_12,
    '''junnyu/roformer_small_discriminator''': 1_28,
    '''junnyu/roformer_small_generator''': 1_28,
}


_UpperCAmelCase    :     Any         =       {
    '''junnyu/roformer_chinese_small''': {'''do_lower_case''': True},
    '''junnyu/roformer_chinese_base''': {'''do_lower_case''': True},
    '''junnyu/roformer_chinese_char_small''': {'''do_lower_case''': True},
    '''junnyu/roformer_chinese_char_base''': {'''do_lower_case''': True},
    '''junnyu/roformer_small_discriminator''': {'''do_lower_case''': True},
    '''junnyu/roformer_small_generator''': {'''do_lower_case''': True},
}







class lowercase_       (		_UpperCamelCase			):







   """simple docstring"""

   __lowerCAmelCase         =   VOCAB_FILES_NAMES
   __lowerCAmelCase         =   PRETRAINED_VOCAB_FILES_MAP
   __lowerCAmelCase         =   PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
   __lowerCAmelCase         =   PRETRAINED_INIT_CONFIGURATION
   __lowerCAmelCase         =   RoFormerTokenizer
   def __init__(      self      :			Dict, UpperCamelCase__      :			Dict=None, UpperCamelCase__      :			List[Any]=None, UpperCamelCase__      :			str=True, UpperCamelCase__      :			Dict="[UNK]", UpperCamelCase__      :			Dict="[SEP]", UpperCamelCase__      :			Optional[Any]="[PAD]", UpperCamelCase__      :			Union[str, Any]="[CLS]", UpperCamelCase__      :			Any="[MASK]", UpperCamelCase__      :			List[Any]=True, UpperCamelCase__      :			str=None, **UpperCamelCase__      :			str, )  ->			Optional[int]:
        super().__init__(
            UpperCamelCase__, tokenizer_file=UpperCamelCase__, do_lower_case=UpperCamelCase__, unk_token=UpperCamelCase__, sep_token=UpperCamelCase__, pad_token=UpperCamelCase__, cls_token=UpperCamelCase__, mask_token=UpperCamelCase__, tokenize_chinese_chars=UpperCamelCase__, strip_accents=UpperCamelCase__, **UpperCamelCase__, )

        _A    		=  json.loads(self.backend_tokenizer.normalizer.__getstate__()     )
        if (
            pre_tok_state.get('lowercase', UpperCamelCase__     ) != do_lower_case
            or pre_tok_state.get('strip_accents', UpperCamelCase__     ) != strip_accents
        ):
             _A    		=  getattr(UpperCamelCase__, pre_tok_state.pop('type'     )     )
             _A    		=  do_lower_case
             _A    		=  strip_accents
             _A    		=  pre_tok_class(**UpperCamelCase__     )

        _A    		=  do_lower_case
   def __getstate__(      self      :			Any     )  ->			List[str]:
        _A    		=  self.__dict__.copy()
        _A    		=  BertPreTokenizer()
        return state
   def __setstate__(      self      :			List[str], UpperCamelCase__      :			int     )  ->			int:
        _A    		=  d
        _A    		=  self.__dict__['_tokenizer'].get_vocab()
        _A    		=  PreTokenizer.custom(JiebaPreTokenizer(UpperCamelCase__     )     )
   def 	__UpperCAmelCase   (      self      :			List[Any], UpperCamelCase__      :			List[str], UpperCamelCase__      :			int=None     )  ->			int:
        _A    		=  [self.cls_token_id] + token_ids_a + [self.sep_token_id]

        if token_ids_a:
             output += token_ids_a + [self.sep_token_id]

        return output
   def 	__UpperCAmelCase   (      self      :			List[str], UpperCamelCase__      :			List[int], UpperCamelCase__      :			Optional[List[int]] = None     )  ->			List[int]:
        _A    		=  [self.sep_token_id]
        _A    		=  [self.cls_token_id]
        if token_ids_a is None:
             return len(cls + token_ids_a + sep     ) * [0]
        return len(cls + token_ids_a + sep     ) * [0] + len(token_ids_a + sep     ) * [1]
   def 	__UpperCAmelCase   (      self      :			Tuple, UpperCamelCase__      :			str, UpperCamelCase__      :			Optional[str] = None     )  ->			Tuple[str]:
        _A    		=  self._tokenizer.model.save(UpperCamelCase__, name=UpperCamelCase__     )
        return tuple(UpperCamelCase__     )

   def 	__UpperCAmelCase   (      self      :			int, UpperCamelCase__      :			int, UpperCamelCase__      :			Dict=None, UpperCamelCase__      :			Dict=None, UpperCamelCase__      :			Tuple=False, **UpperCamelCase__      :			Optional[Any], )  ->			Any:
        _A    		=  BertPreTokenizer()
        return super().save_pretrained(UpperCamelCase__, UpperCamelCase__, UpperCamelCase__, UpperCamelCase__, **UpperCamelCase__     )




'''simple docstring'''






from __future__ import annotations





def  _SCREAMING_SNAKE_CASE		(      __snake_case							:			int | str				):
     _A    		=  str(__snake_case				)
     return n == n[::-1]





def  _SCREAMING_SNAKE_CASE		(      __snake_case							:			int = 1_0_0_0_0_0_0				):
     _A    		=  0

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


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



