




"""simple docstring"""

from math import sqrt






def 		_snake_case	(   _snake_case				:   int				)       ->   int:






      '''simple docstring'''


      _A     =  0
      for i in range(1							,    int(sqrt(_snake_case				) + 1				)				):
            if n % i == 0 and i != sqrt(_snake_case				):
                  total += i + n // i
            elif i == sqrt(_snake_case				):
                  total += i
      return total - n






def 		_snake_case	(   _snake_case				:   int = 1_00_00				)       ->   int:






      '''simple docstring'''


      _A     =  sum(
          i
          for i in range(1							,    _snake_case				)
          if sum_of_divisors(sum_of_divisors(_snake_case				)				) == i and sum_of_divisors(_snake_case				) != i				)
      return total


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







"""simple docstring"""






from __future__ import annotations

from fractions import Fraction
from math import gcd, sqrt







def 	_snake_case     (							lowercase__						):
				_lowerCamelCase	:     int       =       int(number**0.5						)
				return number == sq * sq







def 	_snake_case     (							lowercase__				,       lowercase__				,       lowercase__				,       lowercase__				,       lowercase__				,       lowercase__						):
				_lowerCamelCase	:     int       =       x_num * y_den * z_den + y_num * x_den * z_den + z_num * x_den * y_den
				_lowerCamelCase	:     int       =       x_den * y_den * z_den
				_lowerCamelCase	:     int       =       gcd(lowercase__				,       lowercase__						)
				top //= hcf
				bottom //= hcf
				return top, bottom







def 	_snake_case     (							lowercase__ = 35						):
				_lowerCamelCase	:     set       =       set()
				_lowerCamelCase	:     int
				_lowerCamelCase	:     Fraction       =       Fraction(0						)
				_lowerCamelCase	:     tuple[int, int]

				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
																				_lowerCamelCase	:     int       =       x_num * y_den + x_den * y_num
																				_lowerCamelCase	:     List[Any]       =       x_den * y_den
																				_lowerCamelCase	:     int       =       gcd(lowercase__				,       lowercase__						)
																				z_num //= hcf
																				z_den //= hcf
																				if 0 < z_num < z_den <= order:
																								_lowerCamelCase	:     Optional[Any]       =       add_three(
																								    lowercase__				,       lowercase__				,       lowercase__				,       lowercase__				,       lowercase__				,       lowercase__						)
																								unique_s.add(lowercase__						)

																				# n=2
																				_lowerCamelCase	:     Tuple       =       (
																				    x_num * x_num * y_den * y_den + x_den * x_den * y_num * y_num
																				)
																				_lowerCamelCase	:     Dict       =       x_den * x_den * y_den * y_den
																				if is_sq(lowercase__						) and is_sq(lowercase__						):
																								_lowerCamelCase	:     Dict       =       int(sqrt(lowercase__						)						)
																								_lowerCamelCase	:     Optional[Any]       =       int(sqrt(lowercase__						)						)
																								_lowerCamelCase	:     List[Any]       =       gcd(lowercase__				,       lowercase__						)
																								z_num //= hcf
																								z_den //= hcf
																								if 0 < z_num < z_den <= order:
																												_lowerCamelCase	:     Union[str, Any]       =       add_three(
																												    lowercase__				,       lowercase__				,       lowercase__				,       lowercase__				,       lowercase__				,       lowercase__						)
																												unique_s.add(lowercase__						)

                    # n=-1
																				_lowerCamelCase	:     List[str]       =       x_num * y_num
																				_lowerCamelCase	:     int       =       x_den * y_num + x_num * y_den
																				_lowerCamelCase	:     Dict       =       gcd(lowercase__				,       lowercase__						)
																				z_num //= hcf
																				z_den //= hcf
																				if 0 < z_num < z_den <= order:
																								_lowerCamelCase	:     List[str]       =       add_three(
																								    lowercase__				,       lowercase__				,       lowercase__				,       lowercase__				,       lowercase__				,       lowercase__						)
																								unique_s.add(lowercase__						)

																				# n=2
																				_lowerCamelCase	:     Tuple       =       x_num * x_num * y_num * y_num
																				_lowerCamelCase	:     List[str]       =       (
																				    x_den * x_den * y_num * y_num + x_num * x_num * y_den * y_den
																				)
																				if is_sq(lowercase__						) and is_sq(lowercase__						):
																								_lowerCamelCase	:     Optional[int]       =       int(sqrt(lowercase__						)						)
																								_lowerCamelCase	:     Optional[int]       =       int(sqrt(lowercase__						)						)
																								_lowerCamelCase	:     Dict       =       gcd(lowercase__				,       lowercase__						)
																								z_num //= hcf
																								z_den //= hcf
																								if 0 < z_num < z_den <= order:
																												_lowerCamelCase	:     int       =       add_three(
																												    lowercase__				,       lowercase__				,       lowercase__				,       lowercase__				,       lowercase__				,       lowercase__						)
																												unique_s.add(lowercase__						)

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

				return total.denominator + total.numerator


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