'''simple docstring'''





from __future__ import annotations

from collections.abc import Iterator


class   lowerCamelCase					:
  """simple docstring"""







  def __init__(							self :       int  ,     __magic_name__ :       int   )  ->	str:
        SCREAMING_SNAKE_CASE_          =  value
        SCREAMING_SNAKE_CASE_          =  None
        SCREAMING_SNAKE_CASE_          =  None



class   lowerCamelCase					:
  """simple docstring"""







  def __init__(							self :       int  ,     __magic_name__ :       Node   )  ->	Optional[Any]:
        SCREAMING_SNAKE_CASE_          =  tree







  def    __A     (							self :       str  ,     __magic_name__ :       Node | None   )  ->	Optional[int]:
        if node is None:
              return 0
        return node.value + (
            self.depth_first_search(node.left   ) + self.depth_first_search(node.right   )
        )







  def __iter__(							self :       str   )  ->	int:
        yield self.depth_first_search(self.tree   )


if __name__ == "__main__":
      import doctest

      doctest.testmod()



from __future__ import annotations


def      a__ (		__UpperCamelCase				):
      SCREAMING_SNAKE_CASE_          =  str(__UpperCamelCase				)
      return n == n[::-1]


def      a__ (		__UpperCamelCase = 1_0_0_0_0_0_0				):
      SCREAMING_SNAKE_CASE_          =  0

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


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


