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

using namespace std;

static unsigned int
for_num (unsigned int x)
{
  return min (x + 1, 19 - x);
}

unsigned long long dp[19];

int
main (void)
{
  char buf[32];
  fill (buf, buf + 32, 0);
  scanf ("%s", buf);

  unsigned int n = strlen (buf);

  reverse (buf, buf + n);

  dp[0] = 1;

  for (unsigned int i = 1; i <= n; i ++)
    {
      dp[i] = dp[i - 1] * for_num (buf[i - 1] - '0');

      if (i > 1
          && buf[i - 1] == '1'
          && buf[i - 2] < '9')
        dp[i] += dp[i - 2] * for_num (10 * (buf[i - 1] - '0')
                                      + (buf[i - 2] - '0'));
    }

  printf ("%llu\n", dp[n]);

  return 0;
}