



'''simple docstring'''

snake_case_			=     {str(digit): digit**5 for digit in range(10)}






def       __lowercase  (_SCREAMING_SNAKE_CASE      :int       ):
				return sum(DIGITS_FIFTH_POWER[digit] for digit in str(_SCREAMING_SNAKE_CASE       )       )






def       __lowercase  ():
				return sum(
				    number
				    for number in range(10_00    ,	1_00_00_00       )
				    if number == digits_fifth_powers_sum(_SCREAMING_SNAKE_CASE       )       )


if __name__ == "__main__":
	print(solution())









'''simple docstring'''

from __future__ import annotations






def       __lowercase  (_SCREAMING_SNAKE_CASE      :int | str       ):
				SCREAMING_SNAKE_CASE  :						int      					= str(_SCREAMING_SNAKE_CASE       )
				return n == n[::-1]






def       __lowercase  (_SCREAMING_SNAKE_CASE      :int = 1_00_00_00       ):
				SCREAMING_SNAKE_CASE  :						int      					= 0

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


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




