#P11227. Completing the Deck
Completing the Deck
Completing the Deck
Small P borrowed a deck of n cards from his classmate Q. In this problem, we consider a standard deck of playing cards without the jokers. Each card has two attributes: a suit and a rank. There are 4 suits represented by the characters \(D\) (Diamonds), \(C\) (Clubs), \(H\) (Hearts) and \(S\) (Spades), and 13 ranks represented in increasing order as \(A, 2, 3, 4, 5, 6, 7, 8, 9, T, J, Q, K\) (note that the rank 10 is represented as T
).
A deck is called complete if and only if for every suit and every rank there is exactly one card of that suit and rank, making a total of \(4 \times 13 = 52\) cards. The picture below illustrates all 52 cards in a complete deck.
Since the deck borrowed from Q might be incomplete, Small P plans to borrow some additional cards from his classmate S, who has an unlimited supply of every type of card. Determine the minimum number of cards that P must borrow so that from the cards he has from both Q and S, he can select 52 cards that form a complete deck.
Each card is represented by a 2-character string. The first character indicates the suit (D, C, H, S) and the second character indicates the rank (one of A,2,3,4,5,6,7,8,9,T,J,Q,K). For example, CA
represents the Ace of Clubs and ST
represents the Ten of Spades.
inputFormat
The first line of input contains a single integer \(n\) (\(0 \leq n \leq 52\) or more), representing the number of cards that P initially borrowed from Q.
If \(n > 0\), the second line contains \(n\) space-separated strings each of length 2, denoting the cards. It is possible that some cards appear more than once.
outputFormat
Output a single integer: the minimum number of cards that P must borrow from S so that he can form a complete deck of 52 cards.
sample
0
52