The Mad Hatter's hat-searching quest now continues in a new town.
In this town, there are
The Mad Hatter starts with a single hat of type
Constraints
Input Specification
The first line contains two space-separated integers
Output Specification
Output a single integer: the maximum number of hat types that can be worn.
Sample Input
5 4
4 1 2
5 1 1
2 4 4
3 4 5
Sample Output
4
Explanation for Sample Output
It is possible to wear hats of type 1, 2, 3, and 4 using the sequence of trades
Comments