#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=1000;
int f[N][N],n,t,m,vis[N];
int from[N];
bool dfs(int x){
for(int j=1;j<=m;j++)
{
if(!vis[j] && f[x][j])
{
vis[j]=1;
if(!from[j]||dfs(from[j]))
{
from[j]=x;
return 1;
}
}
}
return 0;
}
signed main(){
cin>>n>>m>>t;
for(int i=1,u,v;i<=t;i++){
cin>>u>>v;
f[u][v] = 1;
}
int ans=0;
for(int i=1;i<=n;i++){
memset(vis,0,sizeof vis);
// memset(from,0,sizeof from);
if(dfs(i)){
ans++;
}
}
cout<<ans;
return 0;
}