#B4268. Last Non-Zero Digit of Factorial

    ID: 11925 Type: Default 1000ms 256MiB

Last Non-Zero Digit of Factorial

Last Non-Zero Digit of Factorial

Given a positive integer N, calculate the last non-zero digit of N!.

Factorials can grow very fast. For example, although 5! = 120, its last non-zero digit is 2. Similarly, 7! = 5040, so the last non-zero digit is 4.

You are required to compute the last digit that is not zero in the factorial of N.

Note: Since factorials grow rapidly, you should take care of intermediate overflow by removing trailing zeros during the multiplication process.

inputFormat

The input consists of a single integer N (1 ≤ N ≤ 10000) given in one line.

outputFormat

Output a single digit which is the last non-zero digit in N!.

sample

5
2