




'''simple docstring'''

from __future__ import annotations

from random import random






class 		a							:


				def __init__(						self       :   Optional[int]			,							lowercase_       :   List[str] = None   ):
									snake_case_		     =							value
									snake_case_		     =							random()
									snake_case_		     =							None
									snake_case_		     =							None


				def __repr__(						self       :   List[Any]   ):
									from pprint import pformat

									if self.left is None and self.right is None:
														return F"\'{self.value}: {self.prior:.5}\'"
									else:
														return pformat(
														    {F"{self.value}: {self.prior:.5}": (self.left, self.right)}			,							indent=1   )


				def __str__(						self       :   Optional[int]   ):
									snake_case_		     =							str(self.value   ) + """ """
									snake_case_		     =							str(self.left or ''''''   )
									snake_case_		     =							str(self.right or ''''''   )
									return value + left + right







def 						__magic_name__       (      __UpperCAmelCase, __UpperCAmelCase      )						->   Dict:

					'''simple docstring'''

					if root is None:  # None tree is split into 2 Nones
										return None, None
					elif root.value is None:
										return None, None
					else:
										if value < root.value:
															snake_case_		     =							split(root.left, lowerCAmelCase__      )
															return left, root
										else:
															snake_case_		     =							split(root.right, lowerCAmelCase__      )
															return root, right


def 						__magic_name__       (      __UpperCAmelCase, __UpperCAmelCase      )						->   Dict:

					'''simple docstring'''

					if (not left) or (not right):  # If one node is None, return the other
										return left or right
					elif left.prior < right.prior:
										snake_case_		     =							merge(left.right, lowerCAmelCase__      )
										return left
					else:
										snake_case_		     =							merge(lowerCAmelCase__, right.left      )
										return right


def 						__magic_name__       (      __UpperCAmelCase, __UpperCAmelCase      )						->   Optional[int]:

					'''simple docstring'''

					snake_case_		     =							Node(lowerCAmelCase__      )
					snake_case_		     =							split(lowerCAmelCase__, lowerCAmelCase__      )
					return merge(merge(lowerCAmelCase__, lowerCAmelCase__      ), lowerCAmelCase__      )


def 						__magic_name__       (      __UpperCAmelCase, __UpperCAmelCase      )						->   Tuple:

					'''simple docstring'''

					snake_case_		     =							split(lowerCAmelCase__, value - 1      )
					snake_case_		     =							split(lowerCAmelCase__, lowerCAmelCase__      )
					return merge(lowerCAmelCase__, lowerCAmelCase__      )


def 						__magic_name__       (      __UpperCAmelCase      )						->   List[Any]:

					'''simple docstring'''

					if not root:  # None
										return
					else:
										inorder(root.left      )
										print(root.value, end=''','''      )
										inorder(root.right      )


def 						__magic_name__       (      __UpperCAmelCase, __UpperCAmelCase      )						->   List[Any]:

					'''simple docstring'''

					for arg in args.split():
										if arg[0] == "+":
															snake_case_		     =							insert(lowerCAmelCase__, int(arg[1:]      )      )

										elif arg[0] == "-":
															snake_case_		     =							erase(lowerCAmelCase__, int(arg[1:]      )      )

										else:
															print('''Unknown command'''      )

					return root


def 						__magic_name__       (      )						->   List[str]:

					'''simple docstring'''

					snake_case_		     =							None
					print(
					    '''enter numbers to create a tree, + value to add value into treap, '''
					    '''- value to erase all nodes with value. \'q\' to quit. '''      )

					snake_case_		     =							input()
					while args != "q":
										snake_case_		     =							interact_treap(lowerCAmelCase__, lowerCAmelCase__      )
										print(lowerCAmelCase__      )
										snake_case_		     =							input()

					print('''good by!'''      )


if __name__ == "__main__":
							import doctest

							doctest.testmod()
							main()






from __future__ import annotations







def  lowerCAmelCase_	(lowerCAmelCase__:		int | str  ):





			"""simple docstring"""


			UpperCAmelCase_:		Optional[int]							      =     str(lowerCAmelCase__  )
			return n == n[::-1]







def  lowerCAmelCase_	(lowerCAmelCase__:		int = 1_0_0_0_0_0_0  ):





			"""simple docstring"""


			UpperCAmelCase_:		int							      =     0

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


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






