//题目连接:http://poj.org/problem?id=1466
//这个题目注意..遍历的点是全部的点.而并不是类似前面的题目一样仅仅是遍历X,Y其中的一个集合..
//对于这样的题目来说的话.做法一就是变成比较标准的二部图的形式,外部遍历X,内部遍历Y..//如果直接在内部和外部都对X+Y的集合进行遍历的话..对于单向边来说的话,求出来的结果是最大匹配..
//但是对于双向边来说的话,求出来的边是最大匹配*2...要注意这点..!
#include <stdio.h>#include <stdlib.h>
#include <string.h>
#include <iostream>
const int inf = 0x3f3f3f;
const int MN = 600;
int ppx[MN],ppy[MN],n;
bool mk[MN],map[MN][MN];
bool vis[MN];
bool path(int x)
{
for(int i = 0 ; i < n ; i++)
{
if(map[x][i] && !mk[i] )
{
mk[i] = 1;
if(ppy[i] == -1 || path(ppy[i]))
{
ppx[x] = i;
ppy[i] = x;
return 1;
}
}
}
return 0;
}
int Maxmatch()
{
memset(ppx,0xff,sizeof(ppx));
memset(ppy,0xff,sizeof(ppy));
int ans = 0;
for(int i = 0 ; i < n ; i++)
{
if(ppx[i] == -1 )
{
memset(mk,0,sizeof(mk));
ans += path(i);
}
}
return ans;
}
int main()
{
while(scanf("%d",&n) != EOF)
{
int x,y;
memset(vis,0,sizeof(vis));
memset(map,0,sizeof(map));
for(int i = 0 ; i < n ; i++)
{
scanf("%d: (%d)",&x,&y);
for(int j = 1 ; j <= y ; j++)
{
scanf("%d",&x);
map[i][x] = 1;
}
}
int ans = Maxmatch();
//ans = n - ans/2;
printf("%d\n",ans);
}
}