






from __future__ import annotations


def   lowerCamelCase__			(     lowercase				):

  """simple docstring"""






  SCREAMING_SNAKE_CASE       :      Any							=    str(_lowerCAmelCase				)
  return len(_lowerCAmelCase				) == 9 and set(_lowerCAmelCase				) == set("123456789"				)


def   lowerCamelCase__			(     ):

  """simple docstring"""






  for base_num in range(9999						,     4999						,     -1				):
    SCREAMING_SNAKE_CASE       :      int							=    100002 * base_num
    if is_9_pandigital(_lowerCAmelCase				):
      return candidate

  for base_num in range(333						,     99						,     -1				):
    SCREAMING_SNAKE_CASE       :      str							=    1002003 * base_num
    if is_9_pandigital(_lowerCAmelCase				):
      return candidate

  return None


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









from __future__ import annotations


def   lowerCamelCase__			(     lowercase				):

  """simple docstring"""






  SCREAMING_SNAKE_CASE       :      Optional[Any]							=    str(lowercase				)
  return n == n[::-1]


def   lowerCamelCase__			(     lowercase = 1000000				):

  """simple docstring"""






  SCREAMING_SNAKE_CASE       :      int							=    0

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


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






