

'''simple docstring'''




import unittest

from transformers import AlbertConfig, is_torch_available
from transformers.models.auto import get_values
from transformers.testing_utils import require_torch, slow, torch_device

from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
  import torch

  from transformers import (
      MODEL_FOR_PRETRAINING_MAPPING,
      AlbertForMaskedLM,
      AlbertForMultipleChoice,
      AlbertForPreTraining,
      AlbertForQuestionAnswering,
      AlbertForSequenceClassification,
      AlbertForTokenClassification,
      AlbertModel,
  )
  from transformers.models.albert.modeling_albert import ALBERT_PRETRAINED_MODEL_ARCHIVE_LIST



class 							lowercase_						:

  '''simple docstring'''





  def __init__(  self ,			a_ ,			a_=1_3 ,			a_=7 ,			a_=True ,			a_=True ,			a_=True ,			a_=True ,			a_=9_9 ,			a_=1_6 ,			a_=3_6 ,			a_=6 ,			a_=6 ,			a_=6 ,			a_=3_7 ,			a_="gelu" ,			a_=0.1 ,			a_=0.1 ,			a_=5_1_2 ,			a_=1_6 ,			a_=2 ,			a_=0.02 ,			a_=3 ,			a_=4 ,			a_=None ,			)				->					str:


    """simple docstring"""
    UpperCAmelCase    				=						parent
    UpperCAmelCase    				=						batch_size
    UpperCAmelCase    				=						seq_length
    UpperCAmelCase    				=						is_training
    UpperCAmelCase    				=						use_input_mask
    UpperCAmelCase    				=						use_token_type_ids
    UpperCAmelCase    				=						use_labels
    UpperCAmelCase    				=						vocab_size
    UpperCAmelCase    				=						embedding_size
    UpperCAmelCase    				=						hidden_size
    UpperCAmelCase    				=						num_hidden_layers
    UpperCAmelCase    				=						num_hidden_groups
    UpperCAmelCase    				=						num_attention_heads
    UpperCAmelCase    				=						intermediate_size
    UpperCAmelCase    				=						hidden_act
    UpperCAmelCase    				=						hidden_dropout_prob
    UpperCAmelCase    				=						attention_probs_dropout_prob
    UpperCAmelCase    				=						max_position_embeddings
    UpperCAmelCase    				=						type_vocab_size
    UpperCAmelCase    				=						type_sequence_label_size
    UpperCAmelCase    				=						initializer_range
    UpperCAmelCase    				=						num_labels
    UpperCAmelCase    				=						num_choices
    UpperCAmelCase    				=						scope
  def     snake_case_      (  self  )				->					Tuple:


    """simple docstring"""
    UpperCAmelCase    				=						ids_tensor([self.batch_size, self.seq_length] ,			self.vocab_size  )

    UpperCAmelCase    				=						None
    if self.use_input_mask:
      UpperCAmelCase    				=						random_attention_mask([self.batch_size, self.seq_length]  )

    UpperCAmelCase    				=						None
    if self.use_token_type_ids:
      UpperCAmelCase    				=						ids_tensor([self.batch_size, self.seq_length] ,			self.type_vocab_size  )

    UpperCAmelCase    				=						None
    UpperCAmelCase    				=						None
    UpperCAmelCase    				=						None
    if self.use_labels:
      UpperCAmelCase    				=						ids_tensor([self.batch_size] ,			self.type_sequence_label_size  )
      UpperCAmelCase    				=						ids_tensor([self.batch_size, self.seq_length] ,			self.num_labels  )
      UpperCAmelCase    				=						ids_tensor([self.batch_size] ,			self.num_choices  )

    UpperCAmelCase    				=						self.get_config()

    return config, input_ids, token_type_ids, input_mask, sequence_labels, token_labels, choice_labels
  def     snake_case_      (  self  )				->					Optional[Any]:


    """simple docstring"""
    return AlbertConfig(
        vocab_size=self.vocab_size ,			hidden_size=self.hidden_size ,			num_hidden_layers=self.num_hidden_layers ,			num_attention_heads=self.num_attention_heads ,			intermediate_size=self.intermediate_size ,			hidden_act=self.hidden_act ,			hidden_dropout_prob=self.hidden_dropout_prob ,			attention_probs_dropout_prob=self.attention_probs_dropout_prob ,			max_position_embeddings=self.max_position_embeddings ,			type_vocab_size=self.type_vocab_size ,			initializer_range=self.initializer_range ,			num_hidden_groups=self.num_hidden_groups ,			)
  def     snake_case_      (  self ,			a_ ,			a_ ,			a_ ,			a_ ,			a_ ,			a_ ,			a_  )				->					Any:


    """simple docstring"""
    UpperCAmelCase    				=						AlbertModel(config=a_  )
    model.to(a_  )
    model.eval()
    UpperCAmelCase    				=						model(a_ ,			attention_mask=a_ ,			token_type_ids=a_  )
    UpperCAmelCase    				=						model(a_ ,			token_type_ids=a_  )
    UpperCAmelCase    				=						model(a_  )
    self.parent.assertEqual(result.last_hidden_state.shape ,			(self.batch_size, self.seq_length, self.hidden_size)  )
    self.parent.assertEqual(result.pooler_output.shape ,			(self.batch_size, self.hidden_size)  )
  def     snake_case_      (  self ,			a_ ,			a_ ,			a_ ,			a_ ,			a_ ,			a_ ,			a_  )				->					Dict:


    """simple docstring"""
    UpperCAmelCase    				=						AlbertForPreTraining(config=a_  )
    model.to(a_  )
    model.eval()
    UpperCAmelCase    				=						model(
        a_ ,			attention_mask=a_ ,			token_type_ids=a_ ,			labels=a_ ,			sentence_order_label=a_ ,			)
    self.parent.assertEqual(result.prediction_logits.shape ,			(self.batch_size, self.seq_length, self.vocab_size)  )
    self.parent.assertEqual(result.sop_logits.shape ,			(self.batch_size, config.num_labels)  )
  def     snake_case_      (  self ,			a_ ,			a_ ,			a_ ,			a_ ,			a_ ,			a_ ,			a_  )				->					Optional[int]:


    """simple docstring"""
    UpperCAmelCase    				=						AlbertForMaskedLM(config=a_  )
    model.to(a_  )
    model.eval()
    UpperCAmelCase    				=						model(a_ ,			attention_mask=a_ ,			token_type_ids=a_ ,			labels=a_  )
    self.parent.assertEqual(result.logits.shape ,			(self.batch_size, self.seq_length, self.vocab_size)  )
  def     snake_case_      (  self ,			a_ ,			a_ ,			a_ ,			a_ ,			a_ ,			a_ ,			a_  )				->					Any:


    """simple docstring"""
    UpperCAmelCase    				=						AlbertForQuestionAnswering(config=a_  )
    model.to(a_  )
    model.eval()
    UpperCAmelCase    				=						model(
        a_ ,			attention_mask=a_ ,			token_type_ids=a_ ,			start_positions=a_ ,			end_positions=a_ ,			)
    self.parent.assertEqual(result.start_logits.shape ,			(self.batch_size, self.seq_length)  )
    self.parent.assertEqual(result.end_logits.shape ,			(self.batch_size, self.seq_length)  )
  def     snake_case_      (  self ,			a_ ,			a_ ,			a_ ,			a_ ,			a_ ,			a_ ,			a_  )				->					str:


    """simple docstring"""
    UpperCAmelCase    				=						self.num_labels
    UpperCAmelCase    				=						AlbertForSequenceClassification(a_  )
    model.to(a_  )
    model.eval()
    UpperCAmelCase    				=						model(a_ ,			attention_mask=a_ ,			token_type_ids=a_ ,			labels=a_  )
    self.parent.assertEqual(result.logits.shape ,			(self.batch_size, self.num_labels)  )
  def     snake_case_      (  self ,			a_ ,			a_ ,			a_ ,			a_ ,			a_ ,			a_ ,			a_  )				->					Optional[int]:


    """simple docstring"""
    UpperCAmelCase    				=						self.num_labels
    UpperCAmelCase    				=						AlbertForTokenClassification(config=a_  )
    model.to(a_  )
    model.eval()
    UpperCAmelCase    				=						model(a_ ,			attention_mask=a_ ,			token_type_ids=a_ ,			labels=a_  )
    self.parent.assertEqual(result.logits.shape ,			(self.batch_size, self.seq_length, self.num_labels)  )
  def     snake_case_      (  self ,			a_ ,			a_ ,			a_ ,			a_ ,			a_ ,			a_ ,			a_  )				->					Optional[Any]:


    """simple docstring"""
    UpperCAmelCase    				=						self.num_choices
    UpperCAmelCase    				=						AlbertForMultipleChoice(config=a_  )
    model.to(a_  )
    model.eval()
    UpperCAmelCase    				=						input_ids.unsqueeze(1  ).expand(-1 ,			self.num_choices ,			-1  ).contiguous()
    UpperCAmelCase    				=						token_type_ids.unsqueeze(1  ).expand(-1 ,			self.num_choices ,			-1  ).contiguous()
    UpperCAmelCase    				=						input_mask.unsqueeze(1  ).expand(-1 ,			self.num_choices ,			-1  ).contiguous()
    UpperCAmelCase    				=						model(
        a_ ,			attention_mask=a_ ,			token_type_ids=a_ ,			labels=a_ ,			)
    self.parent.assertEqual(result.logits.shape ,			(self.batch_size, self.num_choices)  )





  def     snake_case_      (  self  )				->					List[Any]:


    """simple docstring"""
    UpperCAmelCase    				=						self.prepare_config_and_inputs()
    (
        (
        UpperCAmelCase
    )				,   (
        UpperCAmelCase
    )				,   (
        UpperCAmelCase
    )				,   (
        UpperCAmelCase
    )				,   (
        UpperCAmelCase
    )				,   (
        UpperCAmelCase
    )				,   (
        UpperCAmelCase
    )				,   
    )    				=						config_and_inputs
    UpperCAmelCase    				=						{'input_ids': input_ids, 'token_type_ids': token_type_ids, 'attention_mask': input_mask}
    return config, inputs_dict




@require_torch
class 							lowercase_						(		a			,							a			,							unittest.TestCase			):

  '''simple docstring'''





  __lowerCAmelCase       :			Dict     	= (
      (
          AlbertModel,
          AlbertForPreTraining,
          AlbertForMaskedLM,
          AlbertForMultipleChoice,
          AlbertForSequenceClassification,
          AlbertForTokenClassification,
          AlbertForQuestionAnswering,
      )
      if is_torch_available()
      else ()
  )
  __lowerCAmelCase       :			Optional[int]     	= (
      {
          "feature-extraction": AlbertModel,
          "fill-mask": AlbertForMaskedLM,
          "question-answering": AlbertForQuestionAnswering,
          "text-classification": AlbertForSequenceClassification,
          "token-classification": AlbertForTokenClassification,
          "zero-shot": AlbertForSequenceClassification,
      }
      if is_torch_available()
      else {}
  )
  __lowerCAmelCase       :			str     	= True
  def     snake_case_      (  self ,			a_ ,			a_ ,			a_=False  )				->					Optional[Any]:


    """simple docstring"""
    UpperCAmelCase    				=						super()._prepare_for_class(a_ ,			a_ ,			return_labels=a_  )

    if return_labels:
      if model_class in get_values(a_  ):
        UpperCAmelCase    				=						torch.zeros(
            (self.model_tester.batch_size, self.model_tester.seq_length) ,			dtype=torch.long ,			device=a_  )
        UpperCAmelCase    				=						torch.zeros(
            self.model_tester.batch_size ,			dtype=torch.long ,			device=a_  )
    return inputs_dict
  def     snake_case_      (  self  )				->					Optional[Any]:


    """simple docstring"""
    UpperCAmelCase    				=						AlbertModelTester(self  )
    UpperCAmelCase    				=						ConfigTester(self ,			config_class=a_ ,			hidden_size=3_7  )
  def     snake_case_      (  self  )				->					Union[str, Any]:


    """simple docstring"""
    self.config_tester.run_common_tests()
  def     snake_case_      (  self  )				->					str:


    """simple docstring"""
    UpperCAmelCase    				=						self.model_tester.prepare_config_and_inputs()
    self.model_tester.create_and_check_model(*a_  )
  def     snake_case_      (  self  )				->					Dict:


    """simple docstring"""
    UpperCAmelCase    				=						self.model_tester.prepare_config_and_inputs()
    self.model_tester.create_and_check_for_pretraining(*a_  )
  def     snake_case_      (  self  )				->					str:


    """simple docstring"""
    UpperCAmelCase    				=						self.model_tester.prepare_config_and_inputs()
    self.model_tester.create_and_check_for_masked_lm(*a_  )
  def     snake_case_      (  self  )				->					Tuple:


    """simple docstring"""
    UpperCAmelCase    				=						self.model_tester.prepare_config_and_inputs()
    self.model_tester.create_and_check_for_multiple_choice(*a_  )
  def     snake_case_      (  self  )				->					Union[str, Any]:


    """simple docstring"""
    UpperCAmelCase    				=						self.model_tester.prepare_config_and_inputs()
    self.model_tester.create_and_check_for_question_answering(*a_  )
  def     snake_case_      (  self  )				->					Optional[Any]:


    """simple docstring"""
    UpperCAmelCase    				=						self.model_tester.prepare_config_and_inputs()
    self.model_tester.create_and_check_for_sequence_classification(*a_  )
  def     snake_case_      (  self  )				->					str:


    """simple docstring"""
    UpperCAmelCase    				=						self.model_tester.prepare_config_and_inputs()
    for type in ["absolute", "relative_key", "relative_key_query"]:
      UpperCAmelCase    				=						type
      self.model_tester.create_and_check_model(*a_  )





  @slow
  def     snake_case_      (  self  )				->					Dict:


    """simple docstring"""
    for model_name in ALBERT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
      UpperCAmelCase    				=						AlbertModel.from_pretrained(a_  )
      self.assertIsNotNone(a_  )




@require_torch
class 							lowercase_						(		unittest.TestCase			):

  '''simple docstring'''





  @slow
  def     snake_case_      (  self  )				->					List[Any]:


    """simple docstring"""
    UpperCAmelCase    				=						AlbertModel.from_pretrained('albert-base-v2'  )
    UpperCAmelCase    				=						torch.tensor([[0, 3_4_5, 2_3_2, 3_2_8, 7_4_0, 1_4_0, 1_6_9_5, 6_9, 6_0_7_8, 1_5_8_8, 2]]  )
    UpperCAmelCase    				=						torch.tensor([[0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]  )
    with torch.no_grad():
      UpperCAmelCase    				=						model(a_ ,			attention_mask=a_  )[0]
    UpperCAmelCase    				=						torch.Size((1, 1_1, 7_6_8)  )
    self.assertEqual(output.shape ,			a_  )
    UpperCAmelCase    				=						torch.tensor(
        [[[-0.6513, 1.5035, -0.2766], [-0.6515, 1.5046, -0.2780], [-0.6512, 1.5049, -0.2784]]]  )

    self.assertTrue(torch.allclose(output[:, 1:4, 1:4] ,			a_ ,			atol=1E-4  )  )





'''simple docstring'''




from __future__ import annotations


def    lowerCamelCase__		(    SCREAMING_SNAKE_CASE   : int | str    ):
  UpperCAmelCase    				=						str(SCREAMING_SNAKE_CASE    )
  return n == n[::-1]


def    lowerCamelCase__		(    SCREAMING_SNAKE_CASE   : int = 100_0000    ):
  UpperCAmelCase    				=						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()))))


