



'''simple docstring'''

import warnings
from collections import OrderedDict
from typing import Any, Mapping, Optional

from ... import PreTrainedTokenizer
from ...configuration_utils import PretrainedConfig
from ...onnx import OnnxConfig, OnnxConfigWithPast, OnnxSeqaSeqConfigWithPast
from ...onnx.utils import compute_effective_axis_dimension
from ...utils import TensorType, is_torch_available, logging


snake_case_			=     logging.get_logger(__name__)

snake_case_			=     {
    """facebook/bart-large""": """https://huggingface.co/facebook/bart-large/resolve/main/config.json""",
    # See all BART models at https://huggingface.co/models?filter=bart
}


class 	a__     (				_lowercase	):
	__magic_name__		:    Any	    =     "bart"
	__magic_name__		:    List[Any]	    =     ["past_key_values"]
	__magic_name__		:    int	    =     {"num_attention_heads": "encoder_attention_heads", "hidden_size": "d_model"}


	def __init__(self : List[Any],					__UpperCAmelCase : Tuple=50265,					__UpperCAmelCase : List[str]=1024,					__UpperCAmelCase : Union[str, Any]=12,					__UpperCAmelCase : Union[str, Any]=4096,					__UpperCAmelCase : Union[str, Any]=16,					__UpperCAmelCase : List[Any]=12,					__UpperCAmelCase : Dict=4096,					__UpperCAmelCase : Tuple=16,					__UpperCAmelCase : Tuple=0.0,					__UpperCAmelCase : Union[str, Any]=0.0,					__UpperCAmelCase : List[str]="gelu",					__UpperCAmelCase : int=1024,					__UpperCAmelCase : Optional[int]=0.1,					__UpperCAmelCase : List[str]=0.0,					__UpperCAmelCase : Any=0.0,					__UpperCAmelCase : Union[str, Any]=0.02,					__UpperCAmelCase : Optional[Any]=0.0,					__UpperCAmelCase : List[Any]=False,					__UpperCAmelCase : Tuple=True,					__UpperCAmelCase : List[Any]=3,					__UpperCAmelCase : Optional[int]=1,					__UpperCAmelCase : int=0,					__UpperCAmelCase : str=2,					__UpperCAmelCase : str=True,					__UpperCAmelCase : List[Any]=2,					__UpperCAmelCase : List[Any]=2,					**__UpperCAmelCase : List[Any],					)     ->			Union[str, Any]:

					"""simple docstring"""

					SCREAMING_SNAKE_CASE  :						Tuple      					= vocab_size
					SCREAMING_SNAKE_CASE  :						Any      					= max_position_embeddings
					SCREAMING_SNAKE_CASE  :						int      					= d_model
					SCREAMING_SNAKE_CASE  :						Any      					= encoder_ffn_dim
					SCREAMING_SNAKE_CASE  :						Tuple      					= encoder_layers
					SCREAMING_SNAKE_CASE  :						List[Any]      					= encoder_attention_heads
					SCREAMING_SNAKE_CASE  :						List[str]      					= decoder_ffn_dim
					SCREAMING_SNAKE_CASE  :						Any      					= decoder_layers
					SCREAMING_SNAKE_CASE  :						Optional[int]      					= decoder_attention_heads
					SCREAMING_SNAKE_CASE  :						int      					= dropout
					SCREAMING_SNAKE_CASE  :						Optional[Any]      					= attention_dropout
					SCREAMING_SNAKE_CASE  :						List[str]      					= activation_dropout
					SCREAMING_SNAKE_CASE  :						Any      					= activation_function
					SCREAMING_SNAKE_CASE  :						str      					= init_std
					SCREAMING_SNAKE_CASE  :						str      					= encoder_layerdrop
					SCREAMING_SNAKE_CASE  :						List[Any]      					= decoder_layerdrop
					SCREAMING_SNAKE_CASE  :						List[Any]      					= classifier_dropout
					SCREAMING_SNAKE_CASE  :						List[Any]      					= use_cache
					SCREAMING_SNAKE_CASE  :						Tuple      					= encoder_layers
					SCREAMING_SNAKE_CASE  :						int      					= scale_embedding  # scale factor will be sqrt(d_model) if True

					super().__init__(
					    num_labels=__UpperCAmelCase,					pad_token_id=__UpperCAmelCase,					bos_token_id=__UpperCAmelCase,					eos_token_id=__UpperCAmelCase,					is_encoder_decoder=__UpperCAmelCase,					decoder_start_token_id=__UpperCAmelCase,					forced_eos_token_id=__UpperCAmelCase,					**__UpperCAmelCase,					)

					# ensure backward compatibility for BART CNN models
					if self.forced_bos_token_id is None and kwargs.get('''force_bos_token_to_be_generated''',					__UpperCAmelCase      ):
									SCREAMING_SNAKE_CASE  :						str      					= self.bos_token_id
									warnings.warn(
									    F'''Please make sure the config includes `forced_bos_token_id={self.bos_token_id}` in future versions. '''
									    '''The config can simply be saved and uploaded again to be fixed.'''      )



class 	a__     (				_lowercase	):


	@property
	def 				lowercase__  (self : List[str]      )     ->			Mapping[str, Mapping[int, str]]:

					"""simple docstring"""

					if self.task in ["default", "seq2seq-lm"]:
									SCREAMING_SNAKE_CASE  :						str      					= OrderedDict(
									    [
									        ('''input_ids''', {0: '''batch''', 1: '''encoder_sequence'''}),
									        ('''attention_mask''', {0: '''batch''', 1: '''encoder_sequence'''}),
									    ]      )

									if self.use_past:
													SCREAMING_SNAKE_CASE  :						str      					= {0: '''batch'''}
													SCREAMING_SNAKE_CASE  :						List[Any]      					= {0: '''batch''', 1: '''past_decoder_sequence + sequence'''}
									else:
													SCREAMING_SNAKE_CASE  :						Tuple      					= {0: '''batch''', 1: '''decoder_sequence'''}
													SCREAMING_SNAKE_CASE  :						Tuple      					= {0: '''batch''', 1: '''decoder_sequence'''}

									if self.use_past:
													self.fill_with_past_key_values_(__UpperCAmelCase,					direction='''inputs'''      )
					elif self.task == "causal-lm":
									# TODO: figure this case out.
									SCREAMING_SNAKE_CASE  :						Tuple      					= OrderedDict(
									    [
									        ('''input_ids''', {0: '''batch''', 1: '''encoder_sequence'''}),
									        ('''attention_mask''', {0: '''batch''', 1: '''encoder_sequence'''}),
									    ]      )
									if self.use_past:
													SCREAMING_SNAKE_CASE					,					SCREAMING_SNAKE_CASE  :						Dict      					= self.num_layers
													for i in range(__UpperCAmelCase      ):
																	SCREAMING_SNAKE_CASE  :						List[Any]      					= {0: '''batch''', 2: '''past_sequence + sequence'''}
																	SCREAMING_SNAKE_CASE  :						Any      					= {0: '''batch''', 2: '''past_sequence + sequence'''}
					else:
									SCREAMING_SNAKE_CASE  :						Tuple      					= OrderedDict(
									    [
									        ('''input_ids''', {0: '''batch''', 1: '''encoder_sequence'''}),
									        ('''attention_mask''', {0: '''batch''', 1: '''encoder_sequence'''}),
									        ('''decoder_input_ids''', {0: '''batch''', 1: '''decoder_sequence'''}),
									        ('''decoder_attention_mask''', {0: '''batch''', 1: '''decoder_sequence'''}),
									    ]      )

					return common_inputs


	@property
	def 				lowercase__  (self : int      )     ->			Mapping[str, Mapping[int, str]]:

					"""simple docstring"""

					if self.task in ["default", "seq2seq-lm"]:
									SCREAMING_SNAKE_CASE  :						Union[str, Any]      					= super().outputs
					else:
									SCREAMING_SNAKE_CASE  :						List[str]      					= super(__UpperCAmelCase,					self      ).outputs
									if self.use_past:
													SCREAMING_SNAKE_CASE					,					SCREAMING_SNAKE_CASE  :						Optional[Any]      					= self.num_layers
													for i in range(__UpperCAmelCase      ):
																	SCREAMING_SNAKE_CASE  :						Optional[Any]      					= {0: '''batch''', 2: '''past_sequence + sequence'''}
																	SCREAMING_SNAKE_CASE  :						int      					= {0: '''batch''', 2: '''past_sequence + sequence'''}
					return common_outputs


	def 				lowercase__  (self : str,					__UpperCAmelCase : PreTrainedTokenizer,					__UpperCAmelCase : int = -1,					__UpperCAmelCase : int = -1,					__UpperCAmelCase : bool = False,					__UpperCAmelCase : Optional[TensorType] = None,					)     ->			Mapping[str, Any]:

					"""simple docstring"""

					SCREAMING_SNAKE_CASE  :						Dict      					= self._generate_dummy_inputs_for_sequence_classification_and_question_answering(
					    __UpperCAmelCase,					__UpperCAmelCase,					__UpperCAmelCase,					__UpperCAmelCase,					__UpperCAmelCase      )

					# Generate decoder inputs
					SCREAMING_SNAKE_CASE  :						Optional[Any]      					= seq_length if not self.use_past else 1
					SCREAMING_SNAKE_CASE  :						Tuple      					= self._generate_dummy_inputs_for_sequence_classification_and_question_answering(
					    __UpperCAmelCase,					__UpperCAmelCase,					__UpperCAmelCase,					__UpperCAmelCase,					__UpperCAmelCase      )
					SCREAMING_SNAKE_CASE  :						int      					= {F'''decoder_{name}''': tensor for name, tensor in decoder_inputs.items()}
					SCREAMING_SNAKE_CASE  :						Any      					= dict(**__UpperCAmelCase,					**__UpperCAmelCase      )

					if self.use_past:
									if not is_torch_available():
													raise ValueError('''Cannot generate dummy past_keys inputs without PyTorch installed.'''      )
									else:
													import torch
									SCREAMING_SNAKE_CASE					,					SCREAMING_SNAKE_CASE  :						Optional[Any]      					= common_inputs['''input_ids'''].shape
									SCREAMING_SNAKE_CASE  :						int      					= common_inputs['''decoder_input_ids'''].shape[1]
									SCREAMING_SNAKE_CASE					,					SCREAMING_SNAKE_CASE  :						Union[str, Any]      					= self.num_attention_heads
									SCREAMING_SNAKE_CASE  :						Optional[Any]      					= (
									    batch,
									    num_encoder_attention_heads,
									    encoder_seq_length,
									    self._config.hidden_size // num_encoder_attention_heads,
									)
									SCREAMING_SNAKE_CASE  :						Optional[int]      					= decoder_seq_length + 3
									SCREAMING_SNAKE_CASE  :						List[Any]      					= (
									    batch,
									    num_decoder_attention_heads,
									    decoder_past_length,
									    self._config.hidden_size // num_decoder_attention_heads,
									)

									SCREAMING_SNAKE_CASE  :						Dict      					= torch.cat(
									    [common_inputs['''decoder_attention_mask'''], torch.ones(__UpperCAmelCase,					__UpperCAmelCase      )],					dim=1      )

									SCREAMING_SNAKE_CASE  :						List[str]      					= []
									# If the number of encoder and decoder layers are present in the model configuration, both are considered
									SCREAMING_SNAKE_CASE					,					SCREAMING_SNAKE_CASE  :						Tuple      					= self.num_layers
									SCREAMING_SNAKE_CASE  :						Optional[int]      					= min(__UpperCAmelCase,					__UpperCAmelCase      )
									SCREAMING_SNAKE_CASE  :						List[Any]      					= max(__UpperCAmelCase,					__UpperCAmelCase      ) - min_num_layers
									SCREAMING_SNAKE_CASE  :						Optional[Any]      					= '''encoder''' if num_encoder_layers > num_decoder_layers else '''decoder'''

									for _ in range(__UpperCAmelCase      ):
													common_inputs["past_key_values"].append(
													    (
													        torch.zeros(__UpperCAmelCase      ),
													        torch.zeros(__UpperCAmelCase      ),
													        torch.zeros(__UpperCAmelCase      ),
													        torch.zeros(__UpperCAmelCase      ),
													    )      )
									# TODO: test this.
									SCREAMING_SNAKE_CASE  :						Any      					= encoder_shape if remaining_side_name == '''encoder''' else decoder_shape
									for _ in range(__UpperCAmelCase,					__UpperCAmelCase      ):
													common_inputs["past_key_values"].append((torch.zeros(__UpperCAmelCase      ), torch.zeros(__UpperCAmelCase      ))      )
					return common_inputs


	def 				lowercase__  (self : Any,					__UpperCAmelCase : PreTrainedTokenizer,					__UpperCAmelCase : int = -1,					__UpperCAmelCase : int = -1,					__UpperCAmelCase : bool = False,					__UpperCAmelCase : Optional[TensorType] = None,					)     ->			Mapping[str, Any]:

					"""simple docstring"""

					SCREAMING_SNAKE_CASE  :						List[Any]      					= self._generate_dummy_inputs_for_sequence_classification_and_question_answering(
					    __UpperCAmelCase,					__UpperCAmelCase,					__UpperCAmelCase,					__UpperCAmelCase,					__UpperCAmelCase      )

					if self.use_past:
									if not is_torch_available():
													raise ValueError('''Cannot generate dummy past_keys inputs without PyTorch installed.'''      )
									else:
													import torch
									SCREAMING_SNAKE_CASE					,					SCREAMING_SNAKE_CASE  :						List[str]      					= common_inputs['''input_ids'''].shape
									# Not using the same length for past_key_values
									SCREAMING_SNAKE_CASE  :						List[Any]      					= seqlen + 2
									SCREAMING_SNAKE_CASE					,					SCREAMING_SNAKE_CASE  :						Union[str, Any]      					= self.num_layers
									SCREAMING_SNAKE_CASE					,					SCREAMING_SNAKE_CASE  :						Any      					= self.num_attention_heads
									SCREAMING_SNAKE_CASE  :						Optional[int]      					= (
									    batch,
									    num_encoder_attention_heads,
									    past_key_values_length,
									    self._config.hidden_size // num_encoder_attention_heads,
									)

									SCREAMING_SNAKE_CASE  :						str      					= common_inputs['''attention_mask'''].dtype
									SCREAMING_SNAKE_CASE  :						int      					= torch.cat(
									    [common_inputs['''attention_mask'''], torch.ones(__UpperCAmelCase,					__UpperCAmelCase,					dtype=__UpperCAmelCase      )],					dim=1      )
									SCREAMING_SNAKE_CASE  :						List[Any]      					= [
									    (torch.zeros(__UpperCAmelCase      ), torch.zeros(__UpperCAmelCase      )) for _ in range(__UpperCAmelCase      )
									]
					return common_inputs


	def 				lowercase__  (self : Optional[int],					__UpperCAmelCase : PreTrainedTokenizer,					__UpperCAmelCase : int = -1,					__UpperCAmelCase : int = -1,					__UpperCAmelCase : bool = False,					__UpperCAmelCase : Optional[TensorType] = None,					)     ->			Mapping[str, Any]:

					"""simple docstring"""

					SCREAMING_SNAKE_CASE  :						List[Any]      					= compute_effective_axis_dimension(
					    __UpperCAmelCase,					fixed_dimension=OnnxConfig.default_fixed_batch,					num_token_to_add=0      )

					# If dynamic axis (-1) we forward with a fixed dimension of 8 tokens to avoid optimizations made by ONNX
					SCREAMING_SNAKE_CASE  :						str      					= tokenizer.num_special_tokens_to_add(__UpperCAmelCase      )
					SCREAMING_SNAKE_CASE  :						Tuple      					= compute_effective_axis_dimension(
					    __UpperCAmelCase,					fixed_dimension=OnnxConfig.default_fixed_sequence,					num_token_to_add=__UpperCAmelCase      )

					# Generate dummy inputs according to compute batch and sequence
					SCREAMING_SNAKE_CASE  :						Tuple      					= [''' '''.join([tokenizer.unk_token]      ) * seq_length] * batch_size
					SCREAMING_SNAKE_CASE  :						Union[str, Any]      					= dict(tokenizer(__UpperCAmelCase,					return_tensors=__UpperCAmelCase      )      )
					return common_inputs


	def 				lowercase__  (self : Dict,					__UpperCAmelCase : PreTrainedTokenizer,					__UpperCAmelCase : int = -1,					__UpperCAmelCase : int = -1,					__UpperCAmelCase : bool = False,					__UpperCAmelCase : Optional[TensorType] = None,					)     ->			Mapping[str, Any]:

					"""simple docstring"""

					if self.task in ["default", "seq2seq-lm"]:
									SCREAMING_SNAKE_CASE  :						List[Any]      					= self._generate_dummy_inputs_for_default_and_seqaseq_lm(
									    __UpperCAmelCase,					batch_size=__UpperCAmelCase,					seq_length=__UpperCAmelCase,					is_pair=__UpperCAmelCase,					framework=__UpperCAmelCase      )

					elif self.task == "causal-lm":
									SCREAMING_SNAKE_CASE  :						Any      					= self._generate_dummy_inputs_for_causal_lm(
									    __UpperCAmelCase,					batch_size=__UpperCAmelCase,					seq_length=__UpperCAmelCase,					is_pair=__UpperCAmelCase,					framework=__UpperCAmelCase      )
					else:
									SCREAMING_SNAKE_CASE  :						Optional[int]      					= self._generate_dummy_inputs_for_sequence_classification_and_question_answering(
									    __UpperCAmelCase,					batch_size=__UpperCAmelCase,					seq_length=__UpperCAmelCase,					is_pair=__UpperCAmelCase,					framework=__UpperCAmelCase      )

					return common_inputs






	def 				lowercase__  (self : Optional[Any],					__UpperCAmelCase : Any,					__UpperCAmelCase : Optional[int],					__UpperCAmelCase : str,					__UpperCAmelCase : Optional[int]      )     ->			List[Any]:

					"""simple docstring"""

					if self.task in ["default", "seq2seq-lm"]:
									SCREAMING_SNAKE_CASE  :						Optional[int]      					= super()._flatten_past_key_values_(__UpperCAmelCase,					__UpperCAmelCase,					__UpperCAmelCase,					__UpperCAmelCase      )
					else:
									SCREAMING_SNAKE_CASE  :						Any      					= super(__UpperCAmelCase,					self      )._flatten_past_key_values_(
									    __UpperCAmelCase,					__UpperCAmelCase,					__UpperCAmelCase,					__UpperCAmelCase      )









'''simple docstring'''

from __future__ import annotations






def       __lowercase  (_SCREAMING_SNAKE_CASE      :int | str       ):
				SCREAMING_SNAKE_CASE  :						int      					= str(_SCREAMING_SNAKE_CASE       )
				return n == n[::-1]






def       __lowercase  (_SCREAMING_SNAKE_CASE      :int = 1_00_00_00       ):
				SCREAMING_SNAKE_CASE  :						int      					= 0

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


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




