Hide

Problem B
Memory Game

You’re playing memory with David. $2N$ cards are placed face down in a row, each number between $1$ and $N$ shown on two cards. The players take turns choosing two cards, if a player chooses two cards with the same number they earn a point, the cards are removed and the player can make another move. If the player picks two different cards, the cards are replaced and the opponent makes a move. The player with the most points wins.

Before starting, David goes to fetch his lucky necklace. You decide to take a peek at $K$ cards while he’s away. If he lets you start, how many pairs can you find with certainty?

Input

The first line of input contains $N$ ($1 \leq N \leq 10^5$) and $K$ ($0 \leq K \leq 2N$), the highest number on any card and the amount of cards you’ve looked at. We can assume you don’t look at the same card more than once, and that there are always an even amount of cards.

The second line of input contains $K$ space separated integers, the numbers on the cards you have seen.

Output

The number of pairs you can find with certainty.

Sample Input 1 Sample Output 1
9 5
2 2 4 1 1
2
Sample Input 2 Sample Output 2
2 3
1 2 1
2

Please log in to submit a solution to this problem

Log in