




'''simple docstring'''

from __future__ import annotations

from typing import Any



class 		SCREAMING_SNAKE_CASE__  :





			def __init__(      self						:    Optional[int]      ,		a_						:    int      ,		a_						:    int      ,		a_						:    float = 0							):



						"""simple docstring"""




						__snake_case		,     __snake_case			=		row, column
						__snake_case			=		[[default_value for c in range(a_							)] for r in range(a_							)]





			def __str__(      self						:    Dict							):



						"""simple docstring"""




						__snake_case			=		f'''Matrix consist of {self.row} rows and {self.column} columns\n'''

						# Make string identifier
						__snake_case			=		0
						for row_vector in self.array:
									for obj in row_vector:
												__snake_case			=		max(a_      ,		len(str(a_							)							)							)
						__snake_case			=		f'''%{max_element_length}s'''

						# Make string and return
						def single_line(a_						:    list[float]							) -> str:
									nonlocal string_format_identifier
									__snake_case			=		"["
									line += ", ".join(string_format_identifier % (obj,) for obj in row_vector							)
									line += "]"
									return line

						s += "\n".join(single_line(a_							) for row_vector in self.array							)
						return s





			def __repr__(      self						:    Any							):



						"""simple docstring"""




						return str(self							)





			def 							A (      self						:    List[str]      ,		a_						:    tuple[int, int]							):



						"""simple docstring"""




						if not (isinstance(a_      ,		(list, tuple)							) and len(a_							) == 2):
									return False
						elif not (0 <= loc[0] < self.row and 0 <= loc[1] < self.column):
									return False
						else:
									return True





			def __getitem__(      self						:    Tuple      ,		a_						:    tuple[int, int]							):



						"""simple docstring"""




						assert self.validate_indicies(a_							)
						return self.array[loc[0]][loc[1]]





			def __setitem__(      self						:    Tuple      ,		a_						:    tuple[int, int]      ,		a_						:    float							):



						"""simple docstring"""




						assert self.validate_indicies(a_							)
						__snake_case			=		value





			def __add__(      self						:    Any      ,		a_						:    Matrix							):



						"""simple docstring"""




						assert isinstance(a_      ,		a_							)
						assert self.row == another.row and self.column == another.column

						# Add
						__snake_case			=		Matrix(self.row      ,		self.column							)
						for r in range(self.row							):
									for c in range(self.column							):
												__snake_case			=		self[r, c] + another[r, c]
						return result





			def __neg__(      self						:    List[str]							):



						"""simple docstring"""




						__snake_case			=		Matrix(self.row      ,		self.column							)
						for r in range(self.row							):
									for c in range(self.column							):
												__snake_case			=		-self[r, c]
						return result





			def __sub__(      self						:    int      ,		a_						:    Matrix							):



						"""simple docstring"""




						return self + (-another)





			def __mul__(      self						:    Tuple      ,		a_						:    int | float | Matrix							):



						"""simple docstring"""




						if isinstance(a_      ,		(int, float)							):  # Scalar multiplication
									__snake_case			=		Matrix(self.row      ,		self.column							)
									for r in range(self.row							):
												for c in range(self.column							):
															__snake_case			=		self[r, c] * another
									return result
						elif isinstance(a_      ,		a_							):  # Matrix multiplication
									assert self.column == another.row
									__snake_case			=		Matrix(self.row      ,		another.column							)
									for r in range(self.row							):
												for c in range(another.column							):
															for i in range(self.column							):
																		result[r, c] += self[r, i] * another[i, c]
									return result
						else:
									__snake_case			=		f'''Unsupported type given for another ({type(a_							)})'''
									raise TypeError(a_							)





			def 							A (      self						:    Union[str, Any]							):



						"""simple docstring"""




						__snake_case			=		Matrix(self.column      ,		self.row							)
						for r in range(self.row							):
									for c in range(self.column							):
												__snake_case			=		self[r, c]
						return result






			def 							A (      self						:    List[Any]      ,		a_						:    Matrix      ,		a_						:    Matrix							):



						"""simple docstring"""




						assert isinstance(a_      ,		a_							) and isinstance(a_      ,		a_							)
						assert self.row == self.column == u.row == v.row  # u, v should be column vector
						assert u.column == v.column == 1  # u, v should be column vector

						# Calculate
						__snake_case			=		v.transpose()
						__snake_case			=		(v_t * self * u)[0, 0] + 1
						if numerator_factor == 0:
									return None  # It's not invertable
						return self - ((self * u) * (v_t * self) * (1.0 / numerator_factor))


# Testing
if __name__ == "__main__":


						def __UpperCAmelCase	(   )      ->      None:
									# a^(-1)
									__snake_case			=		Matrix(3		,				3		,				0						)
									for i in range(3						):
												__snake_case			=		1
									print(F'''a^(-1) is {ainv}'''						)
									# u, v
									__snake_case			=		Matrix(3		,				1		,				0						)
									__snake_case		,     __snake_case		,     __snake_case			=		1, 2, -3
									__snake_case			=		Matrix(3		,				1		,				0						)
									__snake_case		,     __snake_case		,     __snake_case			=		4, -2, 5
									print(F'''u is {u}'''						)
									print(F'''v is {v}'''						)
									print(F'''uv^T is {u * v.transpose()}'''						)
									# Sherman Morrison
									print(F'''(a + uv^T)^(-1) is {ainv.sherman_morrison(_UpperCAmelCase		,				_UpperCAmelCase						)}'''						)


						def __UpperCAmelCase	(   )      ->      None:
									import doctest

									doctest.testmod()






						testa()








'''simple docstring'''




from __future__ import annotations


def    lowerCamelCase__		(    SCREAMING_SNAKE_CASE   : int | str    ):
  UpperCAmelCase    				=						str(SCREAMING_SNAKE_CASE    )
  return n == n[::-1]


def    lowerCamelCase__		(    SCREAMING_SNAKE_CASE   : int = 100_0000    ):
  UpperCAmelCase    				=						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()))))


