Job Assignment

No attempts yetTime limit2sMemory limit256 MB

Problem

Kangho's company has N employees and M jobs to finish. The employees are numbered 1 to N, and the jobs are numbered 1 to M.

Each employee takes at most one job from the list of jobs that employee can do, and each job is taken by at most one employee.

Given the list of jobs every employee can do, write a program that finds the largest number of jobs among the M jobs that can be finished.

Input

The first line contains the number of employees N and the number of jobs M. (1 ≤ N, M ≤ 1,000)

Each of the next N lines describes one employee. The i-th of those lines contains the number of jobs employee i can do, followed by the numbers of those jobs. The line of an employee who can do no job holds a single 0. The same job number never appears twice on one line.

Output

Print the largest number of jobs that Kangho's company can finish.