




import re
from typing import Callable, List, Optional, Union

import tensorflow as tf


try:
		from tensorflow.keras.optimizers.legacy import Adam
except ImportError:
		from tensorflow.keras.optimizers import Adam
class 						UpperCAmelCase  (							tf.keras.optimizers.schedules.LearningRateSchedule     ):







						'''simple docstring'''





						def __init__(		self				:	Union[str, Any]			,      __lowercase				:	float			,      __lowercase				:	Callable			,      __lowercase				:	int			,      __lowercase				:	float = 1.0			,      __lowercase				:	str = None			,      ):






							"""simple docstring"""






							super().__init__()
							snake_case_						       =	initial_learning_rate
							snake_case_						       =	warmup_steps
							snake_case_						       =	power
							snake_case_						       =	decay_schedule_fn
							snake_case_						       =	name






						def __call__(		self				:	Optional[int]			,      __lowercase				:	Optional[Any]		):






							"""simple docstring"""






							with tf.name_scope(self.name or "WarmUp"		) as name:
								# Implements polynomial warmup. i.e., if global_step < warmup_steps, the
								# learning rate will be `global_step/num_warmup_steps * init_lr`.
								snake_case_						       =	tf.cast(__lowercase			,      tf.floataa		)
								snake_case_						       =	tf.cast(self.warmup_steps			,      tf.floataa		)
								snake_case_						       =	global_step_float / warmup_steps_float
								snake_case_						       =	self.initial_learning_rate * tf.math.pow(__lowercase			,      self.power		)
								return tf.cond(
								    global_step_float < warmup_steps_float			,      lambda: warmup_learning_rate			,      lambda: self.decay_schedule_fn(step - self.warmup_steps		)			,      name=__lowercase			,      )






						def 			snake_case__		(		self				:	List[str]		):






							"""simple docstring"""






							return {
							    "initial_learning_rate": self.initial_learning_rate,
							    "decay_schedule_fn": self.decay_schedule_fn,
							    "warmup_steps": self.warmup_steps,
							    "power": self.power,
							    "name": self.name,
							}







def 		lowerCamelCase__       (						_A	,      _A	,      _A	,      _A = 0.0	,      _A = 0.9	,      _A = 0.9_99	,      _A = 1E-8	,      _A = None	,      _A = None	,      _A = 0.0	,      _A = 1.0	,      _A = None	,      ):







	'''simple docstring'''





	snake_case_						       =	tf.keras.optimizers.schedules.PolynomialDecay(
	    initial_learning_rate=_A	,      decay_steps=num_train_steps - num_warmup_steps	,      end_learning_rate=init_lr * min_lr_ratio	,      power=_A	,      )
	if num_warmup_steps:
		snake_case_						       =	WarmUp(
		    initial_learning_rate=_A	,      decay_schedule_fn=_A	,      warmup_steps=_A	,      )
	if weight_decay_rate > 0.0:
		snake_case_						       =	AdamWeightDecay(
		    learning_rate=_A	,      weight_decay_rate=_A	,      beta_a=_A	,      beta_a=_A	,      epsilon=_A	,      clipnorm=_A	,      global_clipnorm=_A	,      exclude_from_weight_decay=["LayerNorm", "layer_norm", "bias"]	,      include_in_weight_decay=_A	,      )
	else:
		snake_case_						       =	tf.keras.optimizers.Adam(
		    learning_rate=_A	,      beta_a=_A	,      beta_a=_A	,      epsilon=_A	,      clipnorm=_A	,      global_clipnorm=_A	,      )
	# We return the optimizer and the LR scheduler in order to better track the
	# evolution of the LR independently of the optimizer.
	return optimizer, lr_schedule
class 						UpperCAmelCase  (							UpperCAmelCase__     ):







						'''simple docstring'''





						def __init__(		self				:	Dict			,      __lowercase				:	Union[float, tf.keras.optimizers.schedules.LearningRateSchedule] = 0.001			,      __lowercase				:	float = 0.9			,      __lowercase				:	float = 0.999			,      __lowercase				:	float = 1E-7			,      __lowercase				:	bool = False			,      __lowercase				:	float = 0.0			,      __lowercase				:	Optional[List[str]] = None			,      __lowercase				:	Optional[List[str]] = None			,      __lowercase				:	str = "AdamWeightDecay"			,      **__lowercase				:	int			,      ):






							"""simple docstring"""






							super().__init__(__lowercase			,      __lowercase			,      __lowercase			,      __lowercase			,      __lowercase			,      __lowercase			,      **__lowercase		)
							snake_case_						       =	weight_decay_rate
							snake_case_						       =	include_in_weight_decay
							snake_case_						       =	exclude_from_weight_decay






						@classmethod
						def 			snake_case__		(		cls				:	Dict			,      __lowercase				:	Optional[int]		):






							"""simple docstring"""






							snake_case_						       =	{"WarmUp": WarmUp}
							return super(__lowercase			,      cls		).from_config(__lowercase			,      custom_objects=__lowercase		)






						def 			snake_case__		(		self				:	Optional[int]			,      __lowercase				:	Any			,      __lowercase				:	List[str]			,      __lowercase				:	Dict		):






							"""simple docstring"""






							super(__lowercase			,      self		)._prepare_local(__lowercase			,      __lowercase			,      __lowercase		)
							snake_case_						       =	tf.constant(
							    self.weight_decay_rate			,      name="adam_weight_decay_rate"		)






						def 			snake_case__		(		self				:	Tuple			,      __lowercase				:	Any			,      __lowercase				:	Dict			,      __lowercase				:	int		):






							"""simple docstring"""






							snake_case_						       =	self._do_use_weight_decay(var.name		)
							if do_decay:
								return var.assign_sub(
								    learning_rate * var * apply_state[(var.device, var.dtype.base_dtype)]["weight_decay_rate"]			,      use_locking=self._use_locking			,      )
							return tf.no_op()






						def 			snake_case__		(		self				:	List[Any]			,      __lowercase				:	Optional[int]			,      __lowercase				:	Optional[Any]=None			,      **__lowercase				:	Optional[Any]		):






							"""simple docstring"""






							snake_case_       , snake_case_						       =	list(zip(*__lowercase		)		)
							return super(__lowercase			,      self		).apply_gradients(zip(__lowercase			,      __lowercase		)			,      name=__lowercase			,      **__lowercase		)






						def 			snake_case__		(		self				:	Union[str, Any]			,      __lowercase				:	Tuple			,      __lowercase				:	Tuple			,      __lowercase				:	Any		):






							"""simple docstring"""






							if apply_state is None:
								return self._decayed_lr_t[var_dtype], {}

							snake_case_						       =	apply_state or {}
							snake_case_						       =	apply_state.get((var_device, var_dtype)		)
							if coefficients is None:
								snake_case_						       =	self._fallback_apply_state(__lowercase			,      __lowercase		)
								snake_case_						       =	coefficients

							return coefficients["lr_t"], {"apply_state": apply_state}






						def 			snake_case__		(		self				:	List[Any]			,      __lowercase				:	Optional[int]			,      __lowercase				:	List[str]			,      __lowercase				:	List[str]=None		):






							"""simple docstring"""






							snake_case_       , snake_case_						       =	self._get_lr(var.device			,      var.dtype.base_dtype			,      __lowercase		)
							snake_case_						       =	self._decay_weights_op(__lowercase			,      __lowercase			,      __lowercase		)
							with tf.control_dependencies([decay]		):
								return super(__lowercase			,      self		)._resource_apply_dense(__lowercase			,      __lowercase			,      **__lowercase		)






						def 			snake_case__		(		self				:	Optional[Any]			,      __lowercase				:	List[Any]			,      __lowercase				:	List[Any]			,      __lowercase				:	Union[str, Any]			,      __lowercase				:	List[str]=None		):






							"""simple docstring"""






							snake_case_       , snake_case_						       =	self._get_lr(var.device			,      var.dtype.base_dtype			,      __lowercase		)
							snake_case_						       =	self._decay_weights_op(__lowercase			,      __lowercase			,      __lowercase		)
							with tf.control_dependencies([decay]		):
								return super(__lowercase			,      self		)._resource_apply_sparse(__lowercase			,      __lowercase			,      __lowercase			,      **__lowercase		)






						def 			snake_case__		(		self				:	List[Any]		):






							"""simple docstring"""






							snake_case_						       =	super().get_config()
							config.update({"weight_decay_rate": self.weight_decay_rate}		)
							return config






						def 			snake_case__		(		self				:	Optional[int]			,      __lowercase				:	str		):






							"""simple docstring"""






							if self.weight_decay_rate == 0:
								return False

							if self._include_in_weight_decay:
								for r in self._include_in_weight_decay:
									if re.search(__lowercase			,      __lowercase		) is not None:
										return True

							if self._exclude_from_weight_decay:
								for r in self._exclude_from_weight_decay:
									if re.search(__lowercase			,      __lowercase		) is not None:
										return False
							return True







class 						UpperCAmelCase  (							UpperCAmelCase__     ):







						'''simple docstring'''





						def __init__(		self				:	Optional[int]		):






							"""simple docstring"""






							snake_case_						       =	[]
							snake_case_						       =	None






						@property
						def 			snake_case__		(		self				:	Any		):






							"""simple docstring"""






							if self._accum_steps is None:
								snake_case_						       =	tf.Variable(
								    tf.constant(0			,      dtype=tf.intaa		)			,      trainable=__lowercase			,      synchronization=tf.VariableSynchronization.ON_READ			,      aggregation=tf.VariableAggregation.ONLY_FIRST_REPLICA			,      )

							return self._accum_steps.value()






						@property
						def 			snake_case__		(		self				:	Dict		):






							"""simple docstring"""






							if not self._gradients:
								raise ValueError("The accumulator should be called first to initialize the gradients"		)
							return [gradient.value() if gradient is not None else gradient for gradient in self._gradients]






						def __call__(		self				:	Any			,      __lowercase				:	Union[str, Any]		):






							"""simple docstring"""






							if not self._gradients:
								snake_case_						       =	self.step  # Create the step variable.
								self._gradients.extend(
								    [
								        tf.Variable(
								            tf.zeros_like(__lowercase		)			,      trainable=__lowercase			,      synchronization=tf.VariableSynchronization.ON_READ			,      aggregation=tf.VariableAggregation.ONLY_FIRST_REPLICA			,      )
								        if gradient is not None
								        else gradient
								        for gradient in gradients
								    ]		)
							if len(__lowercase		) != len(self._gradients		):
								raise ValueError(f"Expected {len(self._gradients		)} gradients, but got {len(__lowercase		)}"		)

							for accum_gradient, gradient in zip(self._gradients			,      __lowercase		):
								if accum_gradient is not None and gradient is not None:
									accum_gradient.assign_add(__lowercase		)

							self._accum_steps.assign_add(1		)






						def 			snake_case__		(		self				:	int		):






							"""simple docstring"""






							if not self._gradients:
								return
							self._accum_steps.assign(0		)
							for gradient in self._gradients:
								if gradient is not None:
									gradient.assign(tf.zeros_like(__lowercase		)		)






def 		lowerCamelCase__       (						_A				):







	'''simple docstring'''





	snake_case_						       =	1
	for i in range(1	,      num + 1				):
		fact *= i
	return fact


def 		lowerCamelCase__       (						_A				):







	'''simple docstring'''





	snake_case_						       =	0
	while number > 0:
		snake_case_						       =	number % 10
		sum_of_digits += last_digit
		snake_case_						       =	number // 10  # Removing the last_digit from the given number
	return sum_of_digits


def 		lowerCamelCase__       (						_A = 100				):







	'''simple docstring'''





	snake_case_						       =	factorial(_A				)
	snake_case_						       =	split_and_add(_A				)
	return result


if __name__ == "__main__":
		print(solution(int(input("Enter the Number: ").strip())))
