//经典的二分图匹配,留个念。
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
int N, M;
int map[201][201] = {0};
int x[201];
bool vis[201];
void init()
{
int i, j;
for (i = 1; i <= N; i++)
{
scanf("%d", &map[i][0]);
for (j = 1; j <= map[i][0]; j++)
{
scanf("%d", &map[i][j]);
}
}
memset(x, 0, sizeof(x));
}
bool find(int i) // i is cow
{
int j, k;
for (j = 1; j <= map[i][0]; j++)
{
if (vis[map[i][j]]) continue;
k = map[i][j];
vis[k] = 1;// stall is full
if (x[k] == 0 || find(x[k]))
{
x[k] = i;
return 1;
}
}
return 0;
}
int calc()
{
int i, ans = 0;
for (i = 1; i <= N; i++)
{
memset(vis, 0, sizeof(vis));
if (find(i)) ans++;
}
return ans;
}
int main()
{
while (scanf("%d%d", &N, &M) == 2)
{
init();
printf("%d/n", calc());
}
system("pause");
return 0;
}