Card decks

You are given n cards. Each card has a suit:
♦️ Diamonds
♣️ Clubs
❤️ Hearts
♠️ Spades
Suits are given as shorthands: D for diamonds, C for clubs, H for hearts, S for spades, followed by a role which is a number (2, 3, 4, 5, 6, 7, 8, 9, 10) or another letter (A, K, Q, J).
A full deck contains 1 of each of all the possible suit-role pairs.
You are asked to calculate the number of full card decks that are possible to create from the given n cards. It’s guaranteed that it’s possible to create at least 1 deck.
The only line of the input contains n space-separated cards.
The program should print a single integer - the number of complete decks that’s possible to obtain from those n cards.
Input
Output
D2 D3 D4 D5 D6 D7 D8 D9 D10 DA DK DQ DJ C2 C3 C4 C5 C6 C7 C8 C9 C10 CA CK CQ CJ H2 H3 H4 H5 H6 H7 H8 H9 H10 HA HK HQ HJ S2 S3 S4 S5 S6 S7 S8 S9 S10 SA SK SQ SJ D2 D3 D4 D5 D6 D7 D8 D9 D10 DA DK DQ DJ C2 C3 C4 C5 C6 C7 C8 C9 C10 CA CK CQ CJ H2 H3 H4 H5 H6 H7 H8 H9 H10 HA HK HQ HJ S2 S3 S4 S5 S6 S7 S8 S9 S10 SA SK SQ SJ H9 D10
2
 

Constraints

Time limit: 2 seconds

Memory limit: 512 MB

Output limit: 1 MB

To check your solution you need to sign in
Sign in to continue