eolymp
bolt
Try our new interface for solving problems
Problems

Card game

Card game

Returning to Azerbaijan from Indonesia, while waiting for the next flight at the Doha airport, Said, Omar, Fidan and Fuad decided to play cards in order to "effectively" spend their time.

The standard deck contains 52 cards of 13 different denominations (A, K, Q, J, 10, 9, 8, 7, 6, 5, 4, 3 and 2) and 4 suits (, , , ). Each player is dealt 13 cards. The total card score of each player is calculated as follows:

  • each "ace" (A) is 4 points,
  • each "king" (K) is 3 points,
  • each "queen" (Q) is 2 points,
  • each "jack" (J) is 1 points,
  • other cards (in this case we shall mark them as X) count as 0 points.

Since Fuad is new to this game, he first practiced scoring. Thus, the cards were dealt n times, and each time Fuad counted the points of his cards. In the end, he counted all the points.

Now he wants to know if he has calculated the total points correctly or not. Write a program to help him with this task.

Input

The first line contains n (1n10000) integers. Each of the following n lines contains a row of 13 cards, consisting only of characters 'A', 'K', 'Q', 'J', 'X'.

Output

Print the total score for Fuad.

Time limit 1 second
Memory limit 128 MiB
Input example #1
1
KAXXAJXQXAXKJ
Output example #1
22
Input example #2
3
JQXAXJXQXAXKJ
KAXXAJXKXXXKJ
XAXAAJXQXAKKJ
Output example #2
63
Source Azerbaijan 2022: Qualifying exam in the preparation group for the International Olympiad October 29