



'''simple docstring'''

from dataclasses import dataclass
from typing import Optional, Tuple

import torch
from torch import nn
from transformers import RobertaPreTrainedModel, XLMRobertaConfig, XLMRobertaModel
from transformers.utils import ModelOutput

@dataclass
class __snake_case(				_lowerCAmelCase ):


	'''simple docstring'''



	UpperCAmelCase							:   str									=		None
	UpperCAmelCase							:   Optional[Any]									=		None
	UpperCAmelCase							:   List[str]									=		None
	UpperCAmelCase							:   Tuple									=		None







class __snake_case(				_lowerCAmelCase ):


	'''simple docstring'''



	def __init__( self     ,	A_=1     ,	A_=0     ,	A_=2     ,	A_=512     ,	A_="cls"     ,	A_=False     ,	A_=True     ,	**A_     ,	)     ->     Optional[int]:
		super().__init__(pad_token_id=_SCREAMING_SNAKE_CASE     ,	bos_token_id=_SCREAMING_SNAKE_CASE     ,	eos_token_id=_SCREAMING_SNAKE_CASE     ,	**_SCREAMING_SNAKE_CASE				)
		lowerCAmelCase   =     project_dim
		lowerCAmelCase   =     pooler_fn
		lowerCAmelCase   =     learn_encoder
		lowerCAmelCase   =     use_attention_mask







class __snake_case(				_lowerCAmelCase ):


	'''simple docstring'''



	UpperCAmelCase							:   List[Any]									=		[R"pooler", R"logit_scale"]
	UpperCAmelCase							:   int									=		[R"position_ids", R"predictions.decoder.bias"]
	UpperCAmelCase							:   List[Any]									=		"roberta"
	UpperCAmelCase							:   str									=		RobertaSeriesConfig


	def __init__( self     ,	A_				)     ->     List[Any]:
		super().__init__(_SCREAMING_SNAKE_CASE				)
		lowerCAmelCase   =     XLMRobertaModel(_SCREAMING_SNAKE_CASE				)
		lowerCAmelCase   =     nn.Linear(config.hidden_size     ,	config.project_dim				)
		lowerCAmelCase   =     getattr(_SCREAMING_SNAKE_CASE     ,	"""has_pre_transformation"""     ,	_SCREAMING_SNAKE_CASE				)
		if self.has_pre_transformation:
			lowerCAmelCase   =     nn.Linear(config.hidden_size     ,	config.project_dim				)
			lowerCAmelCase   =     nn.LayerNorm(config.hidden_size     ,	eps=config.layer_norm_eps				)
		self.post_init()




	def     __snake_case   ( self     ,	A_ = None     ,	A_ = None     ,	A_ = None     ,	A_ = None     ,	A_ = None     ,	A_ = None     ,	A_ = None     ,	A_ = None     ,	A_ = None     ,	A_ = None     ,	A_ = None     ,	)     ->     Optional[Any]:
		lowerCAmelCase   =     return_dict if return_dict is not None else self.config.use_return_dict

		lowerCAmelCase   =     self.base_model(
		    input_ids=_SCREAMING_SNAKE_CASE     ,	attention_mask=_SCREAMING_SNAKE_CASE     ,	token_type_ids=_SCREAMING_SNAKE_CASE     ,	position_ids=_SCREAMING_SNAKE_CASE     ,	head_mask=_SCREAMING_SNAKE_CASE     ,	inputs_embeds=_SCREAMING_SNAKE_CASE     ,	encoder_hidden_states=_SCREAMING_SNAKE_CASE     ,	encoder_attention_mask=_SCREAMING_SNAKE_CASE     ,	output_attentions=_SCREAMING_SNAKE_CASE     ,	output_hidden_states=True if self.has_pre_transformation else output_hidden_states     ,	return_dict=_SCREAMING_SNAKE_CASE     ,	)

		if self.has_pre_transformation:
			lowerCAmelCase   =     outputs['''hidden_states'''][-2]
			lowerCAmelCase   =     self.pre_LN(_SCREAMING_SNAKE_CASE				)
			lowerCAmelCase   =     self.transformation_pre(_SCREAMING_SNAKE_CASE				)

			return TransformationModelOutput(
			    projection_state=_SCREAMING_SNAKE_CASE     ,	last_hidden_state=outputs.last_hidden_state     ,	hidden_states=outputs.hidden_states     ,	attentions=outputs.attentions     ,	)
		else:
			lowerCAmelCase   =     self.transformation(outputs.last_hidden_state				)
			return TransformationModelOutput(
			    projection_state=_SCREAMING_SNAKE_CASE     ,	last_hidden_state=outputs.last_hidden_state     ,	hidden_states=outputs.hidden_states     ,	attentions=outputs.attentions     ,	)




'''simple docstring'''

from __future__ import annotations






def 		_snake_case		( _SCREAMING_SNAKE_CASE					:						int | str							)      ->						bool:







	"""simple docstring"""
	lowerCAmelCase   =     str(_SCREAMING_SNAKE_CASE							)
	return n == n[::-1]






def 		_snake_case		( _SCREAMING_SNAKE_CASE					:						int = 1_000_000							)      ->						Dict:







	"""simple docstring"""
	lowerCAmelCase   =     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()))))