luogu#P7797. [COCI 2015/2016 #6] BELA

[COCI 2015/2016 #6] BELA

Problem Description

There is a card game called Belote\text{Belote}. The game uses only eight kinds of cards: A, K, Q, J, T, 9, 8, 7.

The rules are to add up the values of all cards and compare who has the larger total value. Each kind of card has two possible values: one value when it is a trump card, and another value when it is a non-trump card. The values are shown in the table below:

Now Mirko\text{Mirko} has 4×N4 \times N cards, and the trump suit is BB. Please compute the sum of the values of all of Mirko's cards.

Input Format

The first line contains an integer NN and a character BB.

In the next 4×N4 \times N lines, each line contains two characters. The first character is the rank of the card, and the second character is the suit of the card. If the suit of the card =B= B, then this card is a trump card.

Output Format

Output one integer: the total value of all of Mirko's cards.

2 S
TH
9C
KS
QS
JS
TD
AD
JH
60
4 H
AH
KH
QH
JH
TH
9H
8H
7H
AS
KS
QS
JS
TS
9S
8S
7S
92

Hint

[Sample 2 Explanation]

The total value of the cards is $11 + 4 + 3 + 20 + 10 + 14 + 0 + 0 + 11 + 4 + 3 + 2 + 10 + 0 + 0 + 0 = 92$.

[Constraints]

For 100%100\% of the testdata, 1N1001 \le N \le 100. BB and the suits of all cards are one of S, H, D, C. The ranks of all cards are one of A, K, Q, J, T, 9, 8, 7.

[Source]

Translated from COCI 2015-2016 CONTEST #6 T1 BELA.

The score of this problem follows the original COCI problem setting, with a full score of 5050.

Translated by ChatGPT 5