



'''simple docstring'''







def  SCREAMING_SNAKE_CASE__ (				SCREAMING_SNAKE_CASE = 1000     ):
		SCREAMING_SNAKE_CASE_						:List[Any]										=      0
		SCREAMING_SNAKE_CASE_						:Optional[int]										=      (n - 1) // 3
		total += ((terms) * (6 + (terms - 1) * 3)) // 2  # total of an A.P.
		SCREAMING_SNAKE_CASE_						:Dict										=      (n - 1) // 5
		total += ((terms) * (10 + (terms - 1) * 5)) // 2
		SCREAMING_SNAKE_CASE_						:Optional[int]										=      (n - 1) // 15
		total -= ((terms) * (30 + (terms - 1) * 15)) // 2
		return total


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





'''simple docstring'''







def  SCREAMING_SNAKE_CASE__ (				SCREAMING_SNAKE_CASE ,		SCREAMING_SNAKE_CASE ,		SCREAMING_SNAKE_CASE     ):
		assert b != 0, "This cannot accept modulo that is == 0"
		if n == 0:
				return 1

		if n % 2 == 1:
				return (bin_exp_mod(SCREAMING_SNAKE_CASE ,		n - 1 ,		SCREAMING_SNAKE_CASE     ) * a) % b

		SCREAMING_SNAKE_CASE_						:List[str]										=      bin_exp_mod(SCREAMING_SNAKE_CASE ,		n / 2 ,		SCREAMING_SNAKE_CASE     )
		return (r * r) % b


if __name__ == "__main__":
							try:
														SCREAMING_SNAKE_CASE__     : Any				=   int(input("""Enter Base : """).strip())
														SCREAMING_SNAKE_CASE__     : str				=   int(input("""Enter Power : """).strip())
														SCREAMING_SNAKE_CASE__     : List[Any]				=   int(input("""Enter Modulo : """).strip())
							except ValueError:
														print("""Invalid literal for integer""")

							print(bin_exp_mod(BASE, POWER, MODULO))
