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

long long amt[25] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1};
string s;

long long cnt(int pos, long long sum)
{
    if (pos >= s.size())
        return sum;
    if (pos == s.size()-1)
        return (amt[s[pos]-'0'] * sum);

    if (s[pos] != '1' || s[pos+1] > '8')
        return cnt(pos+1, amt[s[pos]-'0']*sum);
    return cnt(pos+1, amt[s[pos]-'0']*sum) + cnt(pos+2, amt[s[pos+1]-'0'+10]*sum);
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    cin >> s;
    cout << cnt(0, 1) << '\n';
}