


"""simple docstring"""







import os
from distutils.util import strtobool




def      UpperCAmelCase__ (lowerCAmelCase_						,		lowerCAmelCase_     ):




					'''simple docstring'''


					for e in env_keys:
										__SCREAMING_SNAKE_CASE		     =       int(os.environ.get(lowerCAmelCase_						,		-1     )     )
										if val >= 0:
															return val
					return default




def      UpperCAmelCase__ (lowerCAmelCase_						,		lowerCAmelCase_=False     ):




					'''simple docstring'''


					__SCREAMING_SNAKE_CASE		     =       os.environ.get(lowerCAmelCase_						,		str(lowerCAmelCase_     )     )
					return strtobool(lowerCAmelCase_     ) == 1  # As its name indicates `strtobool` actually returns an int...




def      UpperCAmelCase__ (lowerCAmelCase_						,		lowerCAmelCase_="no"     ):




					'''simple docstring'''


					__SCREAMING_SNAKE_CASE		     =       os.environ.get(lowerCAmelCase_						,		str(lowerCAmelCase_     )     )
					return value




"""simple docstring"""







from __future__ import annotations




def      UpperCAmelCase__ (lowerCAmelCase_     ):




					'''simple docstring'''


					__SCREAMING_SNAKE_CASE		     =       str(lowerCAmelCase_     )
					return n == n[::-1]




def      UpperCAmelCase__ (lowerCAmelCase_ = 100_0000     ):




					'''simple docstring'''


					__SCREAMING_SNAKE_CASE		     =       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()))))
