Every male competitive programmer knows that finding a prom date is both more competitive and more difficult than any programming competition. It's almost time for prom, but the CS nerd still doesn't have a prom date! Of course, he really wants to take the girl out. Unfortunately, he knows this won't happen, so he won't go to the event. Despite this, he is still interested in his options for prom.
There are males and females in the school. Each male is willing to go to prom with a non-negative number of females. Every student is given an identification number. Males are numbered from to and females are separately numbered from to . The CS nerd's ID number is (and he is a male).
Other males will always get to choose a single female for their prom date before the CS nerd does. Once a female is chosen, another male cannot choose her. Males will always try to choose one female they are willing to go to prom with, but this is not always possible. The CS nerd then wonders to himself: "What is the minimum number of females I can choose from?" Can you help him out?
Constraints
In all subtasks:
Subtask | Points | |
---|---|---|
1 | 20 | |
2 | 30 | |
3 | 50 |
Input Specification
The first line of input will contain two integers, and .
lines of input follow. The first integer will be . space-separated integers follow, specifying the ID numbers of the females the male is willing to go to prom with. All of the ID numbers on each line will be distinct.
Output Specification
Output the minimum number of females that the CS nerd can choose from.
Sample Input 1
2 2
1 1
2 1 2
Sample Output 1
0
Explanation for Sample Output 1
If male chooses female , the CS nerd cannot choose any female.
Sample Input 2
3 3
3 1 2 3
3 1 2 3
3 1 2 3
Sample Output 2
1
Sample Input 3
3 4
2 1 2
1 2
2 2 4
Sample Output 3
1
Comments
Sample input
= cs nerd has no standards
This question is pure cringe...
I came to code! Not to be painfully reminded of my problems!
No u
This comment is hidden due to too much negative feedback. Show it anyway.
50% of girls at CCO used pascal
Didn't the guy who beat d also use Pascal?
CS nerd = Jim Gao
Life is hard sometimes.
I'm shocked that he can't get a date.
He needs to learn to go with the flow
He should consider learning the Ford–Fulkerson algorithm.