



'''simple docstring'''

import logging
import os
from typing import List, TextIO, Union

from conllu import parse_incr
from utils_ner import InputExample, Split, TokenClassificationTask


snake_case_			=     logging.getLogger(__name__)


class 	a__     (				_lowercase	):


	def __init__(self : str,					__UpperCAmelCase : Optional[Any]=-1      )     ->			Tuple:

					"""simple docstring"""

					SCREAMING_SNAKE_CASE  :						Dict      					= label_idx


	def 				lowercase__  (self : List[str],					__UpperCAmelCase : Tuple,					__UpperCAmelCase : Union[Split, str]      )     ->			List[InputExample]:

					"""simple docstring"""

					if isinstance(__UpperCAmelCase,					__UpperCAmelCase      ):
									SCREAMING_SNAKE_CASE  :						int      					= mode.value
					SCREAMING_SNAKE_CASE  :						Dict      					= os.path.join(__UpperCAmelCase,					F'''{mode}.txt'''      )
					SCREAMING_SNAKE_CASE  :						Dict      					= 1
					SCREAMING_SNAKE_CASE  :						str      					= []
					with open(__UpperCAmelCase,					encoding='''utf-8'''      ) as f:
									SCREAMING_SNAKE_CASE  :						Union[str, Any]      					= []
									SCREAMING_SNAKE_CASE  :						Union[str, Any]      					= []
									for line in f:
													if line.startswith('''-DOCSTART-'''      ) or line == "" or line == "\n":
																	if words:
																					examples.append(InputExample(guid=F'''{mode}-{guid_index}''',					words=__UpperCAmelCase,					labels=__UpperCAmelCase      )      )
																					guid_index += 1
																					SCREAMING_SNAKE_CASE  :						str      					= []
																					SCREAMING_SNAKE_CASE  :						Optional[Any]      					= []
													else:
																	SCREAMING_SNAKE_CASE  :						Any      					= line.split(''' '''      )
																	words.append(splits[0]      )
																	if len(__UpperCAmelCase      ) > 1:
																					labels.append(splits[self.label_idx].replace('''\n''',					''''''      )      )
																	else:
																					# Examples could have no label for mode = "test"
																					labels.append('''O'''      )
									if words:
													examples.append(InputExample(guid=F'''{mode}-{guid_index}''',					words=__UpperCAmelCase,					labels=__UpperCAmelCase      )      )
					return examples


	def 				lowercase__  (self : Dict,					__UpperCAmelCase : TextIO,					__UpperCAmelCase : TextIO,					__UpperCAmelCase : List      )     ->			int:

					"""simple docstring"""

					SCREAMING_SNAKE_CASE  :						List[Any]      					= 0
					for line in test_input_reader:
									if line.startswith('''-DOCSTART-'''      ) or line == "" or line == "\n":
													writer.write(__UpperCAmelCase      )
													if not preds_list[example_id]:
																	example_id += 1
									elif preds_list[example_id]:
													SCREAMING_SNAKE_CASE  :						Union[str, Any]      					= line.split()[0] + ''' ''' + preds_list[example_id].pop(0      ) + '''\n'''
													writer.write(__UpperCAmelCase      )
									else:
													logger.warning('''Maximum sequence length exceeded: No prediction for \'%s\'.''',					line.split()[0]      )






	def 				lowercase__  (self : Dict,					__UpperCAmelCase : str      )     ->			List[str]:

					"""simple docstring"""

					if path:
									with open(__UpperCAmelCase,					'''r'''      ) as f:
													SCREAMING_SNAKE_CASE  :						int      					= f.read().splitlines()
									if "O" not in labels:
													SCREAMING_SNAKE_CASE  :						List[Any]      					= ['''O'''] + labels
									return labels
					else:
									return ["O", "B-MISC", "I-MISC", "B-PER", "I-PER", "B-ORG", "I-ORG", "B-LOC", "I-LOC"]



class 	a__     (				_lowercase	):


	def __init__(self : Any      )     ->			Optional[Any]:

					"""simple docstring"""

					super().__init__(label_idx=-2      )






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

					"""simple docstring"""

					if path:
									with open(__UpperCAmelCase,					'''r'''      ) as f:
													SCREAMING_SNAKE_CASE  :						int      					= f.read().splitlines()
									if "O" not in labels:
													SCREAMING_SNAKE_CASE  :						str      					= ['''O'''] + labels
									return labels
					else:
									return [
									    "O",
									    "B-ADVP",
									    "B-INTJ",
									    "B-LST",
									    "B-PRT",
									    "B-NP",
									    "B-SBAR",
									    "B-VP",
									    "B-ADJP",
									    "B-CONJP",
									    "B-PP",
									    "I-ADVP",
									    "I-INTJ",
									    "I-LST",
									    "I-PRT",
									    "I-NP",
									    "I-SBAR",
									    "I-VP",
									    "I-ADJP",
									    "I-CONJP",
									    "I-PP",
									]



class 	a__     (				_lowercase	):


	def 				lowercase__  (self : str,					__UpperCAmelCase : Tuple,					__UpperCAmelCase : Union[Split, str]      )     ->			List[InputExample]:

					"""simple docstring"""

					if isinstance(__UpperCAmelCase,					__UpperCAmelCase      ):
									SCREAMING_SNAKE_CASE  :						Dict      					= mode.value
					SCREAMING_SNAKE_CASE  :						Any      					= os.path.join(__UpperCAmelCase,					F'''{mode}.txt'''      )
					SCREAMING_SNAKE_CASE  :						Optional[Any]      					= 1
					SCREAMING_SNAKE_CASE  :						Optional[Any]      					= []

					with open(__UpperCAmelCase,					encoding='''utf-8'''      ) as f:
									for sentence in parse_incr(__UpperCAmelCase      ):
													SCREAMING_SNAKE_CASE  :						Optional[int]      					= []
													SCREAMING_SNAKE_CASE  :						Tuple      					= []
													for token in sentence:
																	words.append(token['''form''']      )
																	labels.append(token['''upos''']      )
													assert len(__UpperCAmelCase      ) == len(__UpperCAmelCase      )
													if words:
																	examples.append(InputExample(guid=F'''{mode}-{guid_index}''',					words=__UpperCAmelCase,					labels=__UpperCAmelCase      )      )
																	guid_index += 1
					return examples


	def 				lowercase__  (self : Optional[int],					__UpperCAmelCase : TextIO,					__UpperCAmelCase : TextIO,					__UpperCAmelCase : List      )     ->			Dict:

					"""simple docstring"""

					SCREAMING_SNAKE_CASE  :						Optional[Any]      					= 0
					for sentence in parse_incr(__UpperCAmelCase      ):
									SCREAMING_SNAKE_CASE  :						Any      					= preds_list[example_id]
									SCREAMING_SNAKE_CASE  :						Union[str, Any]      					= ''''''
									for token in sentence:
													out += F'''{token["form"]} ({token["upos"]}|{s_p.pop(0      )}) '''
									out += "\n"
									writer.write(__UpperCAmelCase      )
									example_id += 1






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

					"""simple docstring"""

					if path:
									with open(__UpperCAmelCase,					'''r'''      ) as f:
													return f.read().splitlines()
					else:
									return [
									    "ADJ",
									    "ADP",
									    "ADV",
									    "AUX",
									    "CCONJ",
									    "DET",
									    "INTJ",
									    "NOUN",
									    "NUM",
									    "PART",
									    "PRON",
									    "PROPN",
									    "PUNCT",
									    "SCONJ",
									    "SYM",
									    "VERB",
									    "X",
									]









'''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()))))




