#include<iostream> #include<stdio.h> #define N 201 #include<vector> #include<string.h> using namespace std; vector<int>g[N]; int result[N],vis[N],n,m; int dfs(int x) { int i,j; for(j=0;j<g[x].size();j++) { i=g[x][j]; if(!vis[i]) { vis[i]=1; if(result[i]==0||dfs(result[i])) { result[i]=x; return 1; } } } return 0; } int main() { int i,num,b; while(~scanf("%d%d",&n,&m)) { memset(result,0,sizeof(result)); for(i=0;i<=n;i++) { g[i].clear(); } //if(n!=m){printf("NO\n");continue;} for(i=1;i<=n;i++) { cin>>num; while(num--) { cin>>b; g[i].push_back(b); } } int ans=0; for(i=1;i<=n;i++) { memset(vis,0,sizeof(vis)); if(dfs(i))ans++; } cout<<ans<<endl; } }