


"""simple docstring"""
from __future__ import annotations






def 		lowercase							(     _snake_case						:      list[int | float]     ,   _snake_case						:      int     ,   _snake_case						:      int     )     ->int | float:
	"""simple docstring"""





	if len(_snake_case     ) == 0:
		raise ValueError('''find_max() arg is an empty sequence'''     )
	if (
	    left >= len(_snake_case     )
	    or left < -len(_snake_case     )
	    or right >= len(_snake_case     )
	    or right < -len(_snake_case     )
	):
		raise IndexError('''list index out of range'''     )
	if left == right:
		return nums[left]
	__snake_case	:						Optional[int]						=				(left + right) >> 1  # the middle
	__snake_case	:						str						=				find_max(_snake_case     ,   _snake_case     ,   _snake_case     )  # find max in range[left, mid]
	__snake_case	:						Optional[int]						=				find_max(_snake_case     ,   mid + 1     ,   _snake_case     )  # find max in range[mid + 1, right]

	return left_max if left_max >= right_max else right_max


if __name__ == "__main__":
			import doctest

			doctest.testmod(verbose=True)









"""simple docstring"""
from __future__ import annotations






def 		lowercase							(     _snake_case						:      int | str     )     ->bool:
	"""simple docstring"""





	__snake_case	:						List[str]						=				str(_snake_case     )
	return n == n[::-1]






def 		lowercase							(     _snake_case						:      int = 1_000_000     )     ->str:
	"""simple docstring"""





	__snake_case	:						Union[str, Any]						=				0

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


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





