#include<bits/stdc++.h>
using namespace std;
#define go(i,a,b) for(int i=a;i<=b;++i)
#define com(i,a,b) for(int i=a;i>=b;--i)
#define mem(a,b) memset(a,b,sizeof(a))
const int inf=0x3f3f3f3f,N=1000+10;
int n1,n2,m,vis[2*N],head[N<<1],match[N<<1],cnt=0;
struct edge{
int nxt,v;
}e[N*N*2];
void add(int u,int v){
e[cnt]=(edge){head[u],v};
head[u]=cnt++;
}
bool dfs(int u){
for(int i=head[u];i+1;i=e[i].nxt){
int v=e[i].v;
if(vis[v]) continue;
vis[v]=1;//必须在此处标记,因为只会标记二分图的一侧
if(!match[v]||dfs(match[v])){
match[v]=u;
return 1;
}
}
return 0;
}
int main(){
//freopen("input.txt","r",stdin);
mem(head,-1);
read(n1),read(n2),read(m);
int x,y,w,ans=0;
go(i,1,m){
read(x),read(y);
if(x>n1||y>n2) continue;
add(x,y+n1);
}
go(i,1,n1){
mem(vis,0);
ans+=dfs(i);
}
cout<<ans;
return 0;
}