jmbg
문제
Every citizen in one country has his own identification number consisting of 19 digits in the format:
DDMMYYYYAAAAAAAAAAC
where digits DD denote day, MM month, and YYYY year of the birth.
Year of birth is a positive integer between 0001 and 9999 inclusive. Year is a leap year if it is divisible by 4, but not by 100 or if it is divisible by 400.
Digits denoted by A can be arbitrary, and C is a control-digit calculated by the following algorithm:
- Denote all the digits in identification number, except the last one, with Z1...Z18
- S = (10*Z1+9*Z2+8*Z3+ ... +2*Z9+10*Z10+9*Z11+8*Z12+ ... +2*Z18) mod 19
- if S ≤ 9 then C = S, otherwise C = 19-S
A few digits have been erased from an identification number and replaced with a character 'X'.
Write a program that will calculate the total number of different correct identification numbers corresponding to the given pattern.
입력
First and only line of input contains the given pattern.
출력
First and only line of output should contain the total number of different correct identification numbers from the problem statement.
Note: the result will fit into the 64-bit signed integer type (int64 in Pascal, long long in C/C++).
예제
예제 1
XX0220051234567890X
28
예제 2
XXXX200577XXXXXXX7X
3650000000
예제 3
0XX52X0512X456X8903
946