1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
#include <iostream>

using namespace std;

long long ile(int n){
  if(n<10)
    return n+1;
  long long out = 0;
  long long last = n % 10;
  if( (n/10) % 10 == 1 )
    out += (9-last) * ile(n/100);
  out += (last+1) * ile(n/10);
  return out;
}

int main(){
  long long n;
  cin >> n;
  cout << ile(n)<<endl;
  return 0;
}