COCI '16 Contest 4 #1 Bridž

View as PDF

Submit solution

Points: 3 (partial)
Time limit: 1.0s
Memory limit: 32M

Problem type

After a few months of playing on his new phone, Mirko has finally decided to find a new hobby. He discovered a card game called bridge!

It is known that bridge is played by four players using a 5252-card deck, 44 suits total (clubs, hearts, diamonds and spades) and 13 values (A, K, Q, J, 10, 9, 8, 7, 6, 5, 4, 3 and 2). At the beginning of the game, each player is dealt 1313 cards.

Before starting the game, each player counts their so-called honor points in the following way:

  • each ace (A) is worth 44 points
  • each king (K) is worth 33 points
  • each queen (Q) is worth 22 points
  • each jack (J) is worth 11 point
  • the remaining cards (that will be denoted with X in this task) are worth 00 points.

Given the fact that Mirko has started playing bridge only recently, he has decided to practice counting points. He dealt himself cards NN times and each time counted his honor points. In the end, he added them up.

He wants to know if he's done a good job. Help Mirko and check!

Input Specification

The first line of input contains the integer NN (1 \leq N \leq 10\,000)(1 \leq N \leq 10\,000) from the task.

Each of the following NN lines contains K_iK_i, a string consisting of characters A, K, Q, J, X, of length 1313, representing the cards Mirko had in his hand after dealing them for the i^\text{th}i^\text{th} time.

Output Specification

The first and only line of output must contain the required sum from the task.

Sample Input 1

1
AKXAKJXXXAXAQ

Sample Output 1

25

Explanation for Sample Output 1

Mirko has a total of 44 aces, 22 kings, 11 queen and 11 jack in his hand. This totals to 4 \times 4 + 2 \times 3 + 1 \times 2 + 1 \times 1 = 254 \times 4 + 2 \times 3 + 1 \times 2 + 1 \times 1 = 25 honor points.

Sample Input 2

4
XXXAXXXXXXJXX
KXAXXXQJAXXXX
AQKQXXXKXXKQX
JXXXXXJXXXXXX

Sample Output 2

40

Comments

There are no comments at the moment.