



'''simple docstring'''

from __future__ import annotations

snake_case_			=     []






def       __lowercase  (_SCREAMING_SNAKE_CASE      :list[list[int]]    ,	_SCREAMING_SNAKE_CASE      :int    ,	_SCREAMING_SNAKE_CASE      :int       ):
				for i in range(len(_SCREAMING_SNAKE_CASE       )       ):
								if board[row][i] == 1:
												return False
				for i in range(len(_SCREAMING_SNAKE_CASE       )       ):
								if board[i][column] == 1:
												return False
				for i, j in zip(range(_SCREAMING_SNAKE_CASE    ,	-1    ,	-1       )    ,	range(_SCREAMING_SNAKE_CASE    ,	-1    ,	-1       )       ):
								if board[i][j] == 1:
												return False
				for i, j in zip(range(_SCREAMING_SNAKE_CASE    ,	-1    ,	-1       )    ,	range(_SCREAMING_SNAKE_CASE    ,	len(_SCREAMING_SNAKE_CASE       )       )       ):
								if board[i][j] == 1:
												return False
				return True






def       __lowercase  (_SCREAMING_SNAKE_CASE      :list[list[int]]    ,	_SCREAMING_SNAKE_CASE      :int       ):
				if row >= len(_SCREAMING_SNAKE_CASE       ):
								solution.append(_SCREAMING_SNAKE_CASE       )
								printboard(_SCREAMING_SNAKE_CASE       )
								print()
								return True
				for i in range(len(_SCREAMING_SNAKE_CASE       )       ):
								if is_safe(_SCREAMING_SNAKE_CASE    ,	_SCREAMING_SNAKE_CASE    ,	_SCREAMING_SNAKE_CASE       ):
												SCREAMING_SNAKE_CASE  :						Union[str, Any]      					= 1
												solve(_SCREAMING_SNAKE_CASE    ,	row + 1       )
												SCREAMING_SNAKE_CASE  :						Tuple      					= 0
				return False






def       __lowercase  (_SCREAMING_SNAKE_CASE      :list[list[int]]       ):
				for i in range(len(_SCREAMING_SNAKE_CASE       )       ):
								for j in range(len(_SCREAMING_SNAKE_CASE       )       ):
												if board[i][j] == 1:
																print('''Q'''    ,	end=''' '''       )
												else:
																print('''.'''    ,	end=''' '''       )
								print()


# n=int(input("The no. of queens"))
snake_case_			=     8
snake_case_			=     [[0 for i in range(n)] for j in range(n)]
solve(board, 0)




print("""The total no. of solutions are :""", len(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()))))




