#include<iostream>
#include<string>
#include<stdlib.h>
using namespace std;
	long long ans = 0;
void dfs(long long s,long long n)
{
	if (s == 0) ans+=n;
	else {
		int t = log10(s);
		//ans += s;
		while (t >= 0)
		{
			long long a = s / pow(10, t);
			//ans += a+n;
			// cout << a << endl;
			long long b = s - a*pow(10, t);
			dfs(b, a + n);
			t--;
		}
	}
}
int main()
{
	long long s;
	cin >> s;
	dfs(s,0);
	cout << ans;

}