



'''simple docstring'''

def 		_snake_case		( _SCREAMING_SNAKE_CASE					:						int = 1_000							)      ->						int:







	"""simple docstring"""
	lowerCAmelCase   =     2**power
	lowerCAmelCase   =     0
	while n:
		lowerCAmelCase,       lowerCAmelCase   =     r + n % 10, n // 10
	return r


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




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