Calculating the sum of digits in the factorial of a number

Swift Hard math

Task «Calculating the sum of digits in the factorial of a number»

Given a natural number n (1 ≤ n ≤ 1000). It is necessary to calculate the factorial of n, and then find the sum of all digits of the resulting factorial. Output this sum. The factorial can be very large, so use long arithmetic or a built-in type capable of working with large numbers (for example, Decimal or NSString for digit-by-digit multiplication).

Input Format

One integer n, 1 ≤ n ≤ 1000.

Output Format

One integer — the sum of the digits of the number n!.

Examples

Example 1

INPUT
5
OUTPUT
3

Example 2

INPUT
1 42
OUTPUT
1

Example 3

INPUT
10
OUTPUT
27

Example 4

INPUT
3 -5 -10 0
OUTPUT
6
main.swift