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

using namespace std;

#define int long long

int foo(const string &s) {
    if (s.empty()) return 1;
    
    string a = s;
    a.pop_back();
    int x = s.back() - '0';
    int res = (x + 1) * foo(a);
    //cout << x << endl;
    if (a.size() && a.back() == '1') {
        a.pop_back();
        res += (9 - x) * foo(a);
    }
    
    return res;
}

int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    string n;
    cin >> n;
    
    cout << foo(n);
    
    return 0;
}