






from __future__ import annotations

from fractions import Fraction
from math import gcd, sqrt

def _UpperCAmelCase   (	a						:	Dict ):
							snake_case__	  =       int(number**0.5 )
							return number == sq * sq

def _UpperCAmelCase   (	a						:	Tuple  ,					a						:	int  ,					a						:	Union[str, Any]  ,					a						:	List[str]  ,					a						:	Optional[int]  ,					a						:	str ):
							snake_case__	  =       x_num * y_den * z_den + y_num * x_den * z_den + z_num * x_den * y_den
							snake_case__	  =       x_den * y_den * z_den
							snake_case__	  =       gcd(a  ,					a )
							top //= hcf
							bottom //= hcf
							return top, bottom

def _UpperCAmelCase   (	a						:	Dict = 35 ):
							snake_case__	  =       set()
							snake_case__	  =       42
							snake_case__	  =       Fraction(0 )
							snake_case__	  =       42

							for x_num in range(1  ,					order + 1 ):
														for x_den in range(x_num + 1  ,					order + 1 ):
																					for y_num in range(1  ,					order + 1 ):
																												for y_den in range(y_num + 1  ,					order + 1 ):
																																			# n=1
																																			snake_case__	  =       x_num * y_den + x_den * y_num
																																			snake_case__	  =       x_den * y_den
																																			snake_case__	  =       gcd(a  ,					a )
																																			z_num //= hcf
																																			z_den //= hcf
																																			if 0 < z_num < z_den <= order:
																																										snake_case__	  =       add_three(
																																										    a  ,					a  ,					a  ,					a  ,					a  ,					a )
																																										unique_s.add(a )

																																			# n=2
																																			snake_case__	  =       (
																																			    x_num * x_num * y_den * y_den + x_den * x_den * y_num * y_num
																																			)
																																			snake_case__	  =       x_den * x_den * y_den * y_den
																																			if is_sq(a ) and is_sq(a ):
																																										snake_case__	  =       int(sqrt(a ) )
																																										snake_case__	  =       int(sqrt(a ) )
																																										snake_case__	  =       gcd(a  ,					a )
																																										z_num //= hcf
																																										z_den //= hcf
																																										if 0 < z_num < z_den <= order:
																																																	snake_case__	  =       add_three(
																																																	    a  ,					a  ,					a  ,					a  ,					a  ,					a )
																																																	unique_s.add(a )

                    # n=-1
																																			snake_case__	  =       x_num * y_num
																																			snake_case__	  =       x_den * y_num + x_num * y_den
																																			snake_case__	  =       gcd(a  ,					a )
																																			z_num //= hcf
																																			z_den //= hcf
																																			if 0 < z_num < z_den <= order:
																																										snake_case__	  =       add_three(
																																										    a  ,					a  ,					a  ,					a  ,					a  ,					a )
																																										unique_s.add(a )

																																			# n=2
																																			snake_case__	  =       x_num * x_num * y_num * y_num
																																			snake_case__	  =       (
																																			    x_den * x_den * y_num * y_num + x_num * x_num * y_den * y_den
																																			)
																																			if is_sq(a ) and is_sq(a ):
																																										snake_case__	  =       int(sqrt(a ) )
																																										snake_case__	  =       int(sqrt(a ) )
																																										snake_case__	  =       gcd(a  ,					a )
																																										z_num //= hcf
																																										z_den //= hcf
																																										if 0 < z_num < z_den <= order:
																																																	snake_case__	  =       add_three(
																																																	    a  ,					a  ,					a  ,					a  ,					a  ,					a )
																																																	unique_s.add(a )

							for num, den in unique_s:
														total += Fraction(a  ,					a )

							return total.denominator + total.numerator


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








def _UpperCAmelCase   (	a						:	int = 1000 ):
							snake_case__  , snake_case__	  =       1, 1
							snake_case__	  =       2
							while True:
														snake_case__	  =       0
														snake_case__	  =       fa + fa
														snake_case__  , snake_case__	  =       fa, f
														index += 1
														for _ in str(a ):
																					i += 1
														if i == n:
																					break
							return index


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