



'''simple docstring'''

def       __lowercase  (_SCREAMING_SNAKE_CASE      :Union[str, Any]       ):
				SCREAMING_SNAKE_CASE  :						List[Any]      					= 0
				SCREAMING_SNAKE_CASE  :						str      					= len(_lowerCamelCase       )

				for i in range(n - 1       ):
								for j in range(i + 1    ,	_lowerCamelCase       ):
												if arr[i] > arr[j]:
																num_inversions += 1

				return num_inversions






def       __lowercase  (_SCREAMING_SNAKE_CASE      :Dict       ):





				if len(_lowerCamelCase       ) <= 1:
								return arr, 0
				SCREAMING_SNAKE_CASE  :						Union[str, Any]      					= len(_lowerCamelCase       ) // 2
				SCREAMING_SNAKE_CASE  :						str      					= arr[0:mid]
				SCREAMING_SNAKE_CASE  :						int      					= arr[mid:]

				SCREAMING_SNAKE_CASE  :						int      					= count_inversions_recursive(_lowerCamelCase       )
				SCREAMING_SNAKE_CASE  :						Dict      					= count_inversions_recursive(_lowerCamelCase       )
				SCREAMING_SNAKE_CASE  :						Union[str, Any]      					= _count_cross_inversions(_lowerCamelCase    ,	_lowerCamelCase       )

				SCREAMING_SNAKE_CASE  :						Union[str, Any]      					= inversion_p + inversions_q + cross_inversions
				return c, num_inversions






def       __lowercase  (_SCREAMING_SNAKE_CASE      :Union[str, Any]    ,	_SCREAMING_SNAKE_CASE      :List[Any]       ):
				SCREAMING_SNAKE_CASE  :						Union[str, Any]      					= []
				SCREAMING_SNAKE_CASE  :						Optional[int]      					= 0
				while i < len(_lowerCamelCase       ) and j < len(_lowerCamelCase       ):
								if p[i] > q[j]:
												# if P[1] > Q[j], then P[k] > Q[k] for all  i < k <= len(P)
												# These are all inversions. The claim emerges from the
												# property that P is sorted.
												num_inversion += len(_lowerCamelCase       ) - i
												r.append(q[j]       )
												j += 1
								else:
												r.append(p[i]       )
												i += 1

				if i < len(_lowerCamelCase       ):
								r.extend(p[i:]       )
				else:
								r.extend(q[j:]       )

				return r, num_inversion






def       __lowercase  ():
				SCREAMING_SNAKE_CASE  :						Optional[int]      					= [10, 2, 1, 5, 5, 2, 11]

				# this arr has 8 inversions:
				# (10, 2), (10, 1), (10, 5), (10, 5), (10, 2), (2, 1), (5, 2), (5, 2)

				SCREAMING_SNAKE_CASE  :						List[str]      					= count_inversions_bf(_lowerCamelCase       )
				SCREAMING_SNAKE_CASE  :						Union[str, Any]      					= count_inversions_recursive(_lowerCamelCase       )

				assert num_inversions_bf == num_inversions_recursive == 8

				print('''number of inversions = '''    ,	_lowerCamelCase       )

				# testing an array with zero inversion (a sorted arr_1)

				arr_a.sort()
				SCREAMING_SNAKE_CASE  :						Any      					= count_inversions_bf(_lowerCamelCase       )
				SCREAMING_SNAKE_CASE  :						List[Any]      					= count_inversions_recursive(_lowerCamelCase       )

				assert num_inversions_bf == num_inversions_recursive == 0
				print('''number of inversions = '''    ,	_lowerCamelCase       )

				# an empty list should also have zero inversions
				SCREAMING_SNAKE_CASE  :						str      					= []
				SCREAMING_SNAKE_CASE  :						int      					= count_inversions_bf(_lowerCamelCase       )
				SCREAMING_SNAKE_CASE  :						Optional[int]      					= count_inversions_recursive(_lowerCamelCase       )

				assert num_inversions_bf == num_inversions_recursive == 0
				print('''number of inversions = '''    ,	_lowerCamelCase       )


if __name__ == "__main__":
	main()






'''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()))))




