#include<cstring>
#include<iostream>
using namespace std;
const int N = 505, M = 1e5 + 5;
int h[N],val[M],ne[M],idx,res;
bool vis[N];
int match[N];
void add(int u,int v)
{
val[idx] = v;
ne[idx] = h[u];
h[u] = idx++;
}
bool find(int k)
{
for(int i=h[k];i!=-1;i=ne[i])
{
int j = val[i];
if(!vis[j])
{
vis[j] = true;
if(!match[j] || find(match[j]))
{
match[j] = k;
return true;
}
}
}
return false;
}
int main()
{
int n1,n2,m;
cin>>n1>>n2>>m;
memset(h,-1,sizeof h);
while(m--)
{
int u,v;
cin>>u>>v;
add(u,v);
}
for(int i=1;i<=n1;i++)
{
memset(vis,false,sizeof vis);
if(find(i)) res++;
}
cout<<res;
return 0;
}
|