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
#include <cstdio>
#include <cstdlib>
#include <algorithm>

using namespace std;

const int N_MAX = 18;

int A[N_MAX];

int f(int x) {
	if (x < 10 && x >= 0) {
		return x + 1;
	} else if (x >= 10 && x < 19) {
		return 19 - x;
	} else {
		return 0;
	}
}

int p(int a, int b) {
	if (A[a] == 0) return 23;
	return A[a] * 10 + A[b];
}

long long int W(int a, int b) {
	if (a == b) return f(A[a]);
	else if (a + 1 == b) return f(p(a, a + 1)) + f(A[a]) * W(a + 1, b);
	else if (a > b) return 0;
	else return f(p(a, a + 1)) * W(a + 2, b) + f(A[a]) * W(a + 1, b);
}

int main() {
	char c;
	int n = 0;
	while ((c = getchar()) != '\n') {
		A[n] = c - '0';
		++n;
	}
	printf("%lld\n", W(0, n - 1));
	return 0;
}