1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <cstdio>
#include <cctype>

int main()
{
	unsigned char digits[20];
	unsigned long long result[20];

	int N=0, c;
	while (std::isdigit(c = getchar())) {
		digits[N++] = c - '0';
	}

	result[N] = 1;
	result[N-1] = digits[N-1] + 1;
	for (int i=N-2; i>=0; --i) {
		result[i] = (digits[i] + 1) * result[i+1];
		if (digits[i] == 1) {
			result[i] += (9 - digits[i+1]) * result[i+2];
		}
	}
	printf("%llu\n", result[0]);
}