






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





def 				lowercase__		(					lowerCamelCase       ):
				_SCREAMING_SNAKE_CASE   :		List[Any]       		=    str(lowerCamelCase       )
				return n == n[::-1]





def 				lowercase__		(					lowerCamelCase = 1_000_000       ):
				_SCREAMING_SNAKE_CASE   :		Optional[Any]       		=    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()))))









"""simple docstring"""
def 				lowercase__		(					lowerCamelCase,						lowerCamelCase       ):
				return numa ^ numa < 0


if __name__ == "__main__":
			import doctest

			doctest.testmod()

