P29732 [洛谷] "EVOI-RD1" Little XinXin
普及
题目描述

Background

A deck of poker cards consists of 54 cards, excluding the jokers, there are 52 cards. In the same deck, a card can only appear once.

A deck of poker cards includes four suits: Spades ($\texttt{spade}$), Hearts ($\texttt{heart}$), Clubs ($\texttt{club}$), and Diamonds ($\texttt{diamond}$). Each suit has 13 cards, ranging from $\texttt{A}$ to $\texttt{K}$.

In this problem, the four suits are represented by $\texttt{S, H, C, D}$.

We agree that any card is represented by suit + rank, and we use $\texttt{T}$ to denote $\texttt{10}$, such as $\texttt{SA, D5, HT, CQ}$.

Problem Description

XinXin has two decks of poker cards without jokers, and she will draw $n$ cards from these decks.

XinXin has created a combination called "Little XinXin", which is defined as follows: any three cards with the same rank and exactly two different suits form a pair of "Little XinXin". For example, $\texttt{H3, S3, S3}$ is a pair of "Little XinXin".

Once these three cards form a "Little XinXin", XinXin will remove them from the deck and they cannot be used again.

Now, XinXin wants you to help her count how many pairs of "Little XinXin" can be formed from these $n$ cards.

Input Format

The first line is a positive integer $n$.

From the second to the $n+1$-th line, each line represents a card.

Output Format

Output the maximum number of pairs of "Little XinXin" that can be formed from these $n$ cards.

Sample Input and Output

Sample Input #1

3
S3
H3
S3

Sample Output #1

1

Sample Input #2

7
ST
ST
HT
HT
CT
CT
DT

Sample Output #2

2

Sample Input #3

6
DA
HA
D4
C5
DA
D4

Sample Output #3

1

Notes

This problem uses bundled testing.

  • Subtask 1 (10 pts): $1 \le n \le 3$.
  • Subtask 2 (20 pts): $1 \le n \le 5$.
  • Subtask 3 (30 pts): $1 \le n \le 20$.
  • Subtask 4 (10 pts): $1 \le n \le 70$.
  • Subtask 5 (30 pts): No special restrictions.

For $100\%$ of the data, $1 \le n \le 104$, and it is guaranteed that the input cards exist in two decks of poker cards without jokers.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
3 S3 H3 S3
样例输出
1