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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include <iostream>
#include <fstream>

using namespace std;

#ifdef USE_CERR_LOG
#define LOG if (true) cerr
#else
#define LOG if (false) cerr
#endif

typedef long long ll;

#ifdef USE_FILE_CIN
ifstream input("../apb.in");
#define cin input
#endif


ll solve (ll n) {
    int digit, prevDigit;
    ll result, prevResult, prevPrevResult;
    
    prevDigit = n % 10;
    prevResult = prevDigit + 1;
    prevPrevResult = 1;
    n /= 10;
    
    while (n > 0) {
        digit = n % 10;
        result = (digit + 1) * prevResult;
        LOG << "A " << digit << ":" << result << endl;
        
        if (digit == 1 && prevDigit < 9) {
            result += (9 - prevDigit) * prevPrevResult;
            LOG << "B " << digit << ":" << result << endl;
        }

        prevDigit = digit;
        prevPrevResult = prevResult;
        prevResult = result;
        n /= 10;
    }
    
    return result;
}


ll solveEntry(ll number) {
    if (number < 20) {
        return number + 1;
    } else {
        return solve(number);
    }
}


int main() {
    ll number;
    ios_base::sync_with_stdio(false);
    
    cin >> number;
    cout << solveEntry(number);
    
	return 0;
}