#include<iostream>
#include<conio.h>
using namespace std;
//tabee
//calulate n! and return result
int fact (int n)
{
	int i, f;
	f = 1;
	for (i = 1; i <= n; i++)
		f *= i;
	return f;
}

int main ()
{
	int vin, sum = 0;
	cout << endl << "Decimal Number = ";
	cin >> vin;
	do
	{
		sum += fact(vin % 10);
		vin = (int) vin / 10;
	}while (vin > 0);
	cout << endl << "Sum of Factorials = " << sum;
	getch();
}


