cho.sh
Notes
Loading...

Last Nonzero Factorial Digit

Time limit

0.3s

Memory limit

128 MB

Problem

Given a positive integer N, write N! in decimal notation and find the rightmost digit that is not 0.

For example, 4! = 24, so the answer is 4. Also, 5! = 120, so the answer is 2.

Input

The first line contains a positive integer N. N is at most 20,000.

Output

Output one digit: the last nonzero digit of N!.