1738.I'm bored with life

Time Limit: 1s Memory Limit: 256MB

Holidays have finished. Thanks to the help of the hacker Leha, Noora managed to enter the university of her dreams which is located in a town Pavlopolis. It's well known that universities provide students with dormitory for the period of university studies. Consequently Noora had to leave Vickopolis and move to Pavlopolis. Thus Leha was left completely alone in a quiet town Vickopolis. He almost even fell into a depression from boredom!

Leha came up with a task for himself to relax a little. He chooses two integers A and B and then calculates the greatest common divisor of integers "A factorial" and "B factorial". Formally the hacker wants to find out GCD(A!,B!). It's well known that the factorial of an integer x is a product of all positive integers less than or equal to x. Thus x!=1 \cdot 2 \cdot 3 \cdot ... \cdot (x-1) \cdot x. For example 4!=1 \cdot 2 \cdot 3 \cdot 4=24. Recall that GCD(x,y) is the largest positive integer q that divides (without a remainder) both x and y.

Leha has learned how to solve this task very effective. You are able to cope with it not worse, aren't you?

Input Format(From the terminal/stdin)

The first and single line contains two integers A and B (1 \le A,B \le 109,min(A,B) \le 12).

Output Format(To the terminal/stdout)

Print a single integer denoting the greatest common divisor of integers A! and B!.

Sample Input

Copy
4 3
 · \n

Sample Output

Copy
6
 \n

Hints

Consider the sample.

4!=1 \cdot 2 \cdot 3 \cdot 4=24. 3!=1 \cdot 2 \cdot 3=6. The greatest common divisor of integers 24 and 6 is exactly 6.

Submit

请先 登录

© 2025 FAQs