






"""simple docstring"""


class 			lowerCamelCase__						:







						def __init__(							self   :    List[str]			,			_lowercase   :    list		):
								A					       = set_counts
								A					       = max(_lowercase		)
								A					       = len(_lowercase		)
								A					       = [1] * num_sets
								A					       = list(range(_lowercase		)		)







						def __a						(							self   :    List[Any]			,			_lowercase   :    int			,			_lowercase   :    int		):
								A					       = self.get_parent(_lowercase		)
								A					       = self.get_parent(_lowercase		)

								if src_parent == dst_parent:
										return False

								if self.ranks[dst_parent] >= self.ranks[src_parent]:
										self.set_counts[dst_parent] += self.set_counts[src_parent]
										A					       = 0
										A					       = dst_parent
										if self.ranks[dst_parent] == self.ranks[src_parent]:
												self.ranks[dst_parent] += 1
										A					       = self.set_counts[dst_parent]
								else:
										self.set_counts[src_parent] += self.set_counts[dst_parent]
										A					       = 0
										A					       = src_parent
										A					       = self.set_counts[src_parent]

								A					       = max(self.max_set			,			_lowercase		)
								return True







						def __a						(							self   :    List[str]			,			_lowercase   :    int		):
								if self.parents[disj_set] == disj_set:
										return disj_set
								A					       = self.get_parent(self.parents[disj_set]		)
								return self.parents[disj_set]









"""simple docstring"""


from math import sqrt







def  __snake_case       (   UpperCamelCase__	)      ->		int:







		"""simple docstring"""





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







def  __snake_case       (   UpperCamelCase__ = 10000	)      ->		int:







		"""simple docstring"""





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


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





