1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
#include <cstdio>

int dig(int n) { return n<10 ? n+1 : n<19 ? 19-n : 0; }
long long data[20];
long long solve(long long n, int id) {
	if (n == 0) return 1;
	if (data[id] > 0) return data[id];
	int n10 = n % 10;
	int n100 = n % 100;
	data[id] = solve(n / 10, id + 1) * dig(n10);
	if (n10 != n100) data[id] += solve(n / 100, id + 2) * dig(n100);
	return data[id];
}
int main() {
	long long n; scanf("%lld", &n);
	printf("%lld\n", solve(n, 0));
	return 0;
}