Question
Digit Factorial Sum
Sam is fascinated by factorials and decides to explore them in a unique way. Given an integer n, he wants to calculate the sum of the factorials of each digit in n. For any digit x, its factorial, x!, is the product of all positive integers from 1 to x. Can you help Sam find the sum of these factorials for each digit in n?
Input
The first line of the input consists of a single integer n.
Constraints
0 ≤ n ≤ 109
Constraints
0 ≤ n ≤ 109
Output
Print an integer denoting the sum of the factorials of the digits of n.
Example
Sample Input
123
Sample Output
9
Explanation
The answer is (1! + 2! + 3!) = 1 + 2 + 6 = 9.
123
Sample Output
9
Explanation
The answer is (1! + 2! + 3!) = 1 + 2 + 6 = 9.