

'''simple docstring'''
from math import sqrt







def  _A		(     snake_case					)      ->     int:
   _lowercase      :				str      					=       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  _A		(     snake_case = 1_00_00					)      ->     int:
   _lowercase      :				List[Any]      					=       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 math import sqrt







def  _A		(     snake_case					)      ->     int:
   _lowercase      :				str      					=       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  _A		(     snake_case = 1_00_00					)      ->     int:
   _lowercase      :				List[Any]      					=       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())))






