1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include<cstdio>
#include<cstring>

long long int dane[19];

long long int licz(char *str) {
	if (strlen(str) == 0) {
		return 1;
	}

	if (str[0] != '1') {
		return dane[str[0] - '0'] * licz(str + 1);

	} else {
		if (strlen(str) == 1) {
			return dane[str[0] - '0'];

		} else if (str[1] == '9') {
			return dane[str[0] - '0'] * licz(str + 1);

		} else {
			int d = (str[0] - '0');
			int j = (str[1] - '0');

			return dane[10 * d + j] * licz(str + 2) + dane[str[0] - '0'] * licz(str + 1);
		}
	}

	return 0;
}

int main() {
	char str[100];
	dane[0] = 1;
	dane[1] = 2;
	dane[2] = 3;
	dane[3] = 4;
	dane[4] = 5;
	dane[5] = 6;
	dane[6] = 7;
	dane[7] = 8;
	dane[8] = 9;
	dane[9] = 10;
	dane[10] = 9;
	dane[11] = 8;
	dane[12] = 7;
	dane[13] = 6;
	dane[14] = 5;
	dane[15] = 4;
	dane[16] = 3;
	dane[17] = 2;
	dane[18] = 1;

	scanf("%s", str);

	printf("%lld", licz(str));

	return 0;
}