Problems
Geunwoo is learning a fun card game.
The game uses 36 cards, consisting of 4 colors: Red, Blue, Yellow, Green.
Each color has cards numbered 1 to 9.
Cards are represented as a color letter and a number:
R= RedB= BlueY= YellowG= Green
For example,
Y8means Yellow 8,B5means Blue 5.
Scoring Rules
You draw 5 cards, and calculate the score as follows:
Five cards of the same color in consecutive numbers → score = 900 + highest number
Example:
Y4, Y3, Y2, Y5, Y6→ 906
Four cards with the same number → score = 800 + number of the four cards
Example:
B3, R3, B7, Y3, G3→ 803
Three cards of one number and two cards of another number → score = 700 + (3-number × 10 + 2-number)
Example:
R5, Y5, G7, B5, Y7→ 757
Five cards of the same color (not consecutive) → score = 600 + highest number
Example:
Y3, Y4, Y8, Y6, Y7→ 608
Five cards in consecutive numbers (not same color) → score = 500 + highest number
Example:
R7, R8, G9, Y6, B5→ 509
Three cards with the same number → score = 400 + that number
Example:
R7, Y7, R2, G7, R5→ 407
Two pairs of the same number → score = 300 + (larger pair × 10 + smaller pair)
Example:
R5, Y5, Y4, G9, B4→ 354
One pair of the same number → score = 200 + that number
Example:
R5, Y2, B5, B3, G4→ 205
None of the above → score = 100 + highest number
Example:
R1, R2, B4, B8, Y5→ 108
If multiple rules apply, use the highest possible score.
Input
5 lines, each line contains a card in the format:<Color Letter> <Number>
There is a space between the color letter and the number.
Output
One line containing the score of the hand.
Example
B 3
B 7
R 1
B 2
Y 7
207