#include #include using namespace std;int n,m,edge,head[1005],vis[1005],match[1005],ans,cnt;struct node{ int v,next;}e[1000005];inline void add(int u,int v){ e[++cnt].v=v; e[cnt].next=head[u]; head[u]=cnt;}inline bool dfs(int u){ for(int i=head[u];i!=-1;i=e[i].next){ if(!vis[e[i].v]){ vis[e[i].v]=1; if(match[e[i].v]==-1||dfs(match[e[i].v])){ match[e[i].v]=u; return 1; } } } return 0;}int main(){ memset(head,-1,sizeof(head)); memset(match,-1,sizeof(match)); scanf("%d%d%d",&n,&m,&edge); for(int i=1;i<=edge;i++){ int u,v; scanf("%d%d",&u,&v); if(u>n||v>m)continue; add(u,v); } for(int i=1;i<=n;i++){ memset(vis,0,sizeof(vis)); ans+=dfs(i); } printf("%d\n",ans);}