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

using namespace std;

int count(string n, int pos) {
    if(pos >= n.size()) {
        return 1;
    }

    int number = n[pos] - '0';
    int result = (number + 1) * count(n, pos + 1);

    if(pos + 1 >= n.size()) {
        return result;
    }

    number = number * 10 + n[pos+1] - '0';
    if(number > 18) {
        return result;
    }

    result += (10 - (number - 9)) * count(n, pos + 2);
    return result;
}

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