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
#include <iostream>
#include <string>

using namespace std;

unsigned long long solve(string n, int pos) {
	if (pos == n.length()) {
		return 1;
	}
	if (pos == n.length() - 1) {
		return (n[pos] - '0' + 1);
	}
	if (n[pos] != '1') {
		return ((n[pos] - '0' + 1)*solve(n, pos + 1));
	}
	if (n[pos] == '1') {
		return (2 * solve(n, pos + 1) + (9 - (n[pos + 1] - '0')) * solve(n, pos + 2));
	}
}

int main()
{
	string n;
	cin >> n;
	cout << solve(n, 0);
	return 0;
}