jmbg | 프로그래밍의 벗 PivotOJ
PivotOJ

jmbg

시간 제한: 2000ms메모리 제한: 128MB출처: CHC 2005 National Competition #1 - SeniorsBOJ 1664

문제

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: 

  1. Denote all the digits in identification number, except the last one, with Z1...Z18 
  2. S = (10*Z1+9*Z2+8*Z3+ ... +2*Z9+10*Z10+9*Z11+8*Z12+ ... +2*Z18) mod 19 
  3. 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
코드를 제출하려면 로그인하세요.