


"""simple docstring"""


import collections
import gzip
import os
import urllib

import numpy
from tensorflow.python.framework import dtypes, random_seed
from tensorflow.python.platform import gfile
from tensorflow.python.util.deprecation import deprecated

UpperCamelCase						:				Optional[Any]             =      collections.namedtuple("_Datasets", ["train", "validation", "test"])

# CVDF mirror of http://yann.lecun.com/exdb/mnist/
UpperCamelCase						:				str             =      "https://storage.googleapis.com/cvdf-datasets/mnist/"







def  __snake_case       (   UpperCamelCase__	)      ->		Dict:







		"""simple docstring"""





		A					       = numpy.dtype(numpy.uintaa	).newbyteorder('>'	)
		return numpy.frombuffer(bytestream.read(4	) ,			dtype=UpperCamelCase__	)[0]







@deprecated(UpperCamelCase__ ,			'Please use tf.data to implement this functionality.'	)
def  __snake_case       (   UpperCamelCase__	)      ->		Optional[Any]:







		"""simple docstring"""





		print('Extracting' ,			f.name	)
		with gzip.GzipFile(fileobj=UpperCamelCase__	) as bytestream:
				A					       = _readaa(UpperCamelCase__	)
				if magic != 2051:
						raise ValueError(
						    'Invalid magic number %d in MNIST image file: %s' % (magic, f.name)	)
				A					       = _readaa(UpperCamelCase__	)
				A					       = _readaa(UpperCamelCase__	)
				A					       = _readaa(UpperCamelCase__	)
				A					       = bytestream.read(rows * cols * num_images	)
				A					       = numpy.frombuffer(UpperCamelCase__ ,			dtype=numpy.uinta	)
				A					       = data.reshape(UpperCamelCase__ ,			UpperCamelCase__ ,			UpperCamelCase__ ,			1	)
				return data







@deprecated(UpperCamelCase__ ,			'Please use tf.one_hot on tensors.'	)
def  __snake_case       (   UpperCamelCase__ ,			UpperCamelCase__	)      ->		Union[str, Any]:







		"""simple docstring"""





		A					       = labels_dense.shape[0]
		A					       = numpy.arange(UpperCamelCase__	) * num_classes
		A					       = numpy.zeros((num_labels, num_classes)	)
		A					       = 1
		return labels_one_hot







@deprecated(UpperCamelCase__ ,			'Please use tf.data to implement this functionality.'	)
def  __snake_case       (   UpperCamelCase__ ,			UpperCamelCase__=False ,			UpperCamelCase__=10	)      ->		Tuple:







		"""simple docstring"""





		print('Extracting' ,			f.name	)
		with gzip.GzipFile(fileobj=UpperCamelCase__	) as bytestream:
				A					       = _readaa(UpperCamelCase__	)
				if magic != 2049:
						raise ValueError(
						    'Invalid magic number %d in MNIST label file: %s' % (magic, f.name)	)
				A					       = _readaa(UpperCamelCase__	)
				A					       = bytestream.read(UpperCamelCase__	)
				A					       = numpy.frombuffer(UpperCamelCase__ ,			dtype=numpy.uinta	)
				if one_hot:
						return _dense_to_one_hot(UpperCamelCase__ ,			UpperCamelCase__	)
				return labels



class 			lowerCamelCase__						:







						@deprecated(
						    _lowercase			,			'Please use alternatives such as official/mnist/_DataSet.py'
						    ' from tensorflow/models.'			,			)
						def __init__(							self   :    Any			,			_lowercase   :    Union[str, Any]			,			_lowercase   :    Optional[Any]			,			_lowercase   :    Tuple=False			,			_lowercase   :    int=False			,			_lowercase   :    Dict=dtypes.floataa			,			_lowercase   :    Optional[int]=True			,			_lowercase   :    List[Any]=None			,			):
								A       , A					       = random_seed.get_seed(_lowercase		)
								# If op level seed is not set, use whatever graph level seed is returned
								numpy.random.seed(seeda if seed is None else seeda		)
								A					       = dtypes.as_dtype(_lowercase		).base_dtype
								if dtype not in (dtypes.uinta, dtypes.floataa):
										raise TypeError('Invalid image dtype %r, expected uint8 or float32' % dtype		)
								if fake_data:
										A					       = 10_000
										A					       = one_hot
								else:
										assert (
										    images.shape[0] == labels.shape[0]
										), f'images.shape: {images.shape} labels.shape: {labels.shape}'
										A					       = images.shape[0]

										# Convert shape from [num examples, rows, columns, depth]
										# to [num examples, rows*columns] (assuming depth == 1)
										if reshape:
												assert images.shape[3] == 1
												A					       = images.reshape(
												    images.shape[0]			,			images.shape[1] * images.shape[2]		)
										if dtype == dtypes.floataa:
												# Convert from [0, 255] -> [0.0, 1.0].
												A					       = images.astype(numpy.floataa		)
												A					       = numpy.multiply(_lowercase			,			1.0 / 2_5_5.0		)
								A					       = images
								A					       = labels
								A					       = 0
								A					       = 0







						@property
						def __a						(							self   :    Optional[Any]		):
								return self._images







						@property
						def __a						(							self   :    Optional[Any]		):
								return self._labels







						@property
						def __a						(							self   :    List[Any]		):
								return self._num_examples







						@property
						def __a						(							self   :    str		):
								return self._epochs_completed







						def __a						(							self   :    List[Any]			,			_lowercase   :    Dict			,			_lowercase   :    Optional[Any]=False			,			_lowercase   :    int=True		):
								if fake_data:
										A					       = [1] * 784
										A					       = [1] + [0] * 9 if self.one_hot else 0
										return (
										    [fake_image for _ in range(_lowercase		)],
										    [fake_label for _ in range(_lowercase		)],
										)
								A					       = self._index_in_epoch
								# Shuffle for the first epoch
								if self._epochs_completed == 0 and start == 0 and shuffle:
										A					       = numpy.arange(self._num_examples		)
										numpy.random.shuffle(_lowercase		)
										A					       = self.images[perma]
										A					       = self.labels[perma]
								# Go to the next epoch
								if start + batch_size > self._num_examples:
										# Finished epoch
										self._epochs_completed += 1
										# Get the rest examples in this epoch
										A					       = self._num_examples - start
										A					       = self._images[start : self._num_examples]
										A					       = self._labels[start : self._num_examples]
										# Shuffle the data
										if shuffle:
												A					       = numpy.arange(self._num_examples		)
												numpy.random.shuffle(_lowercase		)
												A					       = self.images[perm]
												A					       = self.labels[perm]
										# Start next epoch
										A					       = 0
										A					       = batch_size - rest_num_examples
										A					       = self._index_in_epoch
										A					       = self._images[start:end]
										A					       = self._labels[start:end]
										return (
										    numpy.concatenate((images_rest_part, images_new_part)			,			axis=0		),
										    numpy.concatenate((labels_rest_part, labels_new_part)			,			axis=0		),
										)
								else:
										self._index_in_epoch += batch_size
										A					       = self._index_in_epoch
										return self._images[start:end], self._labels[start:end]







@deprecated(UpperCamelCase__ ,			'Please write your own downloading logic.'	)
def  __snake_case       (   UpperCamelCase__ ,			UpperCamelCase__ ,			UpperCamelCase__	)      ->		Optional[int]:







		"""simple docstring"""





		if not gfile.Exists(UpperCamelCase__	):
				gfile.MakeDirs(UpperCamelCase__	)
		A					       = os.path.join(UpperCamelCase__ ,			UpperCamelCase__	)
		if not gfile.Exists(UpperCamelCase__	):
				urllib.request.urlretrieve(UpperCamelCase__ ,			UpperCamelCase__	)  # noqa: S310
				with gfile.GFile(UpperCamelCase__	) as f:
						A					       = f.size()
				print('Successfully downloaded' ,			UpperCamelCase__ ,			UpperCamelCase__ ,			'bytes.'	)
		return filepath







@deprecated(
    UpperCamelCase__ ,			'Please use alternatives such as:' ' tensorflow_datasets.load(\'mnist\')'	)
def  __snake_case       (   UpperCamelCase__ ,			UpperCamelCase__=False ,			UpperCamelCase__=False ,			UpperCamelCase__=dtypes.floataa ,			UpperCamelCase__=True ,			UpperCamelCase__=5000 ,			UpperCamelCase__=None ,			UpperCamelCase__=DEFAULT_SOURCE_URL ,			)      ->		int:







		"""simple docstring"""





		if fake_data:

				def fake():
						return _DataSet(
						    [] ,			[] ,			fake_data=UpperCamelCase__ ,			one_hot=UpperCamelCase__ ,			dtype=UpperCamelCase__ ,			seed=UpperCamelCase__	)

				A					       = fake()
				A					       = fake()
				A					       = fake()
				return _Datasets(train=UpperCamelCase__ ,			validation=UpperCamelCase__ ,			test=UpperCamelCase__	)

		if not source_url:  # empty string check
				A					       = DEFAULT_SOURCE_URL

		A					       = 'train-images-idx3-ubyte.gz'
		A					       = 'train-labels-idx1-ubyte.gz'
		A					       = 't10k-images-idx3-ubyte.gz'
		A					       = 't10k-labels-idx1-ubyte.gz'

		A					       = _maybe_download(
		    UpperCamelCase__ ,			UpperCamelCase__ ,			source_url + train_images_file	)
		with gfile.Open(UpperCamelCase__ ,			'rb'	) as f:
				A					       = _extract_images(UpperCamelCase__	)

		A					       = _maybe_download(
		    UpperCamelCase__ ,			UpperCamelCase__ ,			source_url + train_labels_file	)
		with gfile.Open(UpperCamelCase__ ,			'rb'	) as f:
				A					       = _extract_labels(UpperCamelCase__ ,			one_hot=UpperCamelCase__	)

		A					       = _maybe_download(
		    UpperCamelCase__ ,			UpperCamelCase__ ,			source_url + test_images_file	)
		with gfile.Open(UpperCamelCase__ ,			'rb'	) as f:
				A					       = _extract_images(UpperCamelCase__	)

		A					       = _maybe_download(
		    UpperCamelCase__ ,			UpperCamelCase__ ,			source_url + test_labels_file	)
		with gfile.Open(UpperCamelCase__ ,			'rb'	) as f:
				A					       = _extract_labels(UpperCamelCase__ ,			one_hot=UpperCamelCase__	)

		if not 0 <= validation_size <= len(UpperCamelCase__	):
				A					       = (
				    'Validation size should be between 0 and '
				    f'{len(UpperCamelCase__	)}. Received: {validation_size}.'
				)
				raise ValueError(UpperCamelCase__	)

		A					       = train_images[:validation_size]
		A					       = train_labels[:validation_size]
		A					       = train_images[validation_size:]
		A					       = train_labels[validation_size:]

		A					       = {'dtype': dtype, 'reshape': reshape, 'seed': seed}

		A					       = _DataSet(UpperCamelCase__ ,			UpperCamelCase__ ,			**UpperCamelCase__	)
		A					       = _DataSet(UpperCamelCase__ ,			UpperCamelCase__ ,			**UpperCamelCase__	)
		A					       = _DataSet(UpperCamelCase__ ,			UpperCamelCase__ ,			**UpperCamelCase__	)

		return _Datasets(train=UpperCamelCase__ ,			validation=UpperCamelCase__ ,			test=UpperCamelCase__	)









"""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())))





