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
#include <bits/stdc++.h>

using namespace std;

#define LL long long 
#define ULL unsigned LL
#define LD long double

ULL w = 0;

int toint(char x) {
	return x - '0';
}

void trackback(int n, ULL ob, string x, int dl) {
	//cout<<n<<endl;
	if(n>=dl) {
		w+=ob;
		//cout<<ob<<endl;
	}
	else {
		if(n!=(dl-1)) {
			LL oby = toint(x[n]) * 10 + toint(x[n+1]);
			if(oby<=18 && oby >= 10) {
				int mina = 18 - oby;
				LL wx = mina + 1;
				ULL obx = (ULL) wx * ob;
				trackback(n+2, obx, x, dl);
			}
		}
		LL oby = toint(x[n]);
		if(oby>=0 && oby<=9) {
			LL wx = oby+1;
			ULL obx = (ULL) wx * ob;
			trackback(n+1, obx, x, dl);
		}
	}
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	string n;
	cin>>n;
	int dl = n.size();
	//cout<<dl<<endl;
	trackback(0, 1, n, dl);
	cout<<w;
}