
'''simple docstring'''

from __future__ import annotations






def 	_snake_case						(      A_       :    int | str   ):
  """simple docstring"""







  a_      :	List[str]      =							str(A_   )
  return n == n[::-1]






def 	_snake_case						(      A_       :    int = 100_0000   ):
  """simple docstring"""







  a_      :	Tuple      =							0

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


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




'''simple docstring'''

from math import factorial

__snake_case:  List[Any]								=			{str(d): factorial(d) for d in range(10)}






def 	_snake_case						(      A_       :    int   ):
  """simple docstring"""







  return sum(DIGIT_FACTORIAL[d] for d in str(A_   )   )






def 	_snake_case						(      ):
  """simple docstring"""







  a_      :	Union[str, Any]      =							7 * factorial(9   ) + 1
  return sum(i for i in range(3     ,		A_   ) if sum_of_digit_factorial(A_   ) == i   )


if __name__ == "__main__":
    print(F"""{solution() = }""")


