from __future__ import annotations

from math import ceil, floor, sqrt


def __a (	__lowerCamelCase			:						int = 2_000_000				)	->							int:
      '''simple docstring'''


      lowercase_     =      [0]
      lowercase_     =      42

      for idx in range(1 ,		ceil(sqrt(target * 2				) * 1.1				)				):
            triangle_numbers.append(triangle_numbers[-1] + idx				)

      # we want this to be as close as possible to target
      lowercase_     =      0
      # the area corresponding to the grid that gives the product closest to target
      lowercase_     =      0
      # an estimate of b, using the quadratic formula
      lowercase_     =      42
      # the largest integer less than b_estimate
      lowercase_     =      42
      # the largest integer less than b_estimate
      lowercase_     =      42
      # the triangle number corresponding to b_floor
      lowercase_     =      42
      # the triangle number corresponding to b_ceil
      lowercase_     =      42

      for idx_a, triangle_a in enumerate(triangle_numbers[1:] ,		1				):
            lowercase_     =      (-1 + sqrt(1 + 8 * target / triangle_a				)) / 2
            lowercase_     =      floor(__lowerCamelCase				)
            lowercase_     =      ceil(__lowerCamelCase				)
            lowercase_     =      triangle_numbers[b_floor]
            lowercase_     =      triangle_numbers[b_ceil]

            if abs(target - triangle_b_first_guess * triangle_a				) < abs(
                target - best_product				):
                  lowercase_     =      triangle_b_first_guess * triangle_a
                  lowercase_     =      idx_a * b_floor

            if abs(target - triangle_b_second_guess * triangle_a				) < abs(
                target - best_product				):
                  lowercase_     =      triangle_b_second_guess * triangle_a
                  lowercase_     =      idx_a * b_ceil

      return area


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







'''simple docstring'''

from __future__ import annotations


def __a (	__lowerCamelCase			:						int | str				)	->							bool:
      '''simple docstring'''


      lowercase_     =      str(__lowerCamelCase				)
      return n == n[::-1]


def __a (	__lowerCamelCase			:						int = 1_000_000				)	->							Optional[int]:
      '''simple docstring'''


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






