cho.sh
Notes
Loading...

Finding Notebook Owners

Time limit

2s

Memory limit

128 MB

Problem

N students bought new laptops yesterday. One day, while they were changing seats, their laptops got mixed up. Most students recognized their own laptops, but these N students had bought theirs only a day earlier and were not sure which laptop belonged to them.

Each student listed every laptop that could be theirs. You are given M pieces of information saying that student a thinks laptop b may be theirs.

Each student can receive at most one laptop, and each laptop can be given to at most one student. Assign laptops so that as many students as possible receive a laptop they listed as a candidate. Find the maximum number of satisfied students.

Input

The first line contains the number of students N and the number of candidate relations M. N is between 1 and 100, inclusive, and M is between 0 and 5,000, inclusive.

Each of the next M lines contains two integers a and b. This means student a thinks laptop b may be theirs.

All student numbers and laptop numbers are between 1 and N, inclusive.

Output

Output the maximum number of students that can be satisfied.