Problem I. Digitalization

Input file:input.txt   Time limit:2 sec
Output file:output.txt   Memory limit:64 Mb

Statement

Define the function rm sum_of_digits(a) 〈 a ∈ N0〉   = ki = 0ai where {ai} is the representation of a in the numeral system with radix 10.

Define the function:

rm digitalization(a) 〈 a ∈ N0〉   = {
  bf if  rm sum_of_digits(a) ∈ 0..9  {
   bf return  rm sum_of_digits(a)
  }
  bf else  {
   bf return  rm digitalization(rm sum_of_digits(a))
  }
}

Your problem is to find rm digitalization(n!) for given n.

Input file format

n

Output file format

rm digitalization(n!)

Constraints

1 ≤ n ≤ 109

Sample tests

No. Input file (input.txt) Output file (output.txt)
1
2
2
2
3
6

0.066s 0.010s 13