



"""simple docstring"""
from math import sqrt





def      __magic_name__				(							lowercase ):
			SCREAMING_SNAKE_CASE_: Any     			=0
			for i in range(1							,			int(sqrt(lowerCAmelCase__ ) + 1 ) ):
						if n % i == 0 and i != sqrt(lowerCAmelCase__ ):
									total += i + n // i
						elif i == sqrt(lowerCAmelCase__ ):
									total += i
			return total - n





def      __magic_name__				(							lowercase = 1_0000 ):
			SCREAMING_SNAKE_CASE_: List[str]     			=sum(
			    i
			    for i in range(1							,			lowerCAmelCase__ )
			    if sum_of_divisors(sum_of_divisors(lowerCAmelCase__ ) ) == i and sum_of_divisors(lowerCAmelCase__ ) != i )
			return total


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








"""simple docstring"""
def      __magic_name__				(							lowercase = 200_0000 ):
   SCREAMING_SNAKE_CASE_: List[Any]     			=[0 for i in range(n + 1 )]
   SCREAMING_SNAKE_CASE_: Union[str, Any]     			=1
   SCREAMING_SNAKE_CASE_: Optional[Any]     			=1

   for i in range(2							,			int(n**0.5 ) + 1 ):
      if primality_list[i] == 0:
         for j in range(i * i							,			n + 1							,			lowercase ):
            SCREAMING_SNAKE_CASE_: Optional[int]     			=1
   SCREAMING_SNAKE_CASE_: Dict     			=0
   for i in range(lowercase ):
      if primality_list[i] == 0:
         sum_of_primes += i
   return sum_of_primes


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



