User: axuhongbo
Time: 2019-07-26 16:58:57
#include<cstdio>
#include<bits/stdc++.h>

using namespace std;
const  int  N = 1010;
int Map[N][N];
bool vis[N];
int n,m,e,ans,match[N];
int dfs(int x){
   for(int i=1;i<=m;i++){
     if(!vis[i]&&Map[x][i]){
        vis[i] = 1;
        if(!match[i]||dfs(match[i])){
            match[i] = x;
            return 1;
        }
     }
   }
   return 0;
}
void hungry(){
   for(int i=1;i<=n;i++){
      memset(vis,0,sizeof vis);
      ans+=dfs(i);
   }
}
int main() {

   ios::sync_with_stdio(0);
    cin>>n>>m>>e;
    for(int i=1;i<=e;i++){
       int u,v;
       cin>>u>>v;
       if(v<=m&&u<=n){
         Map[u][v] = 1;
       }
    }
    hungry();
    cout<<ans<<endl;
	return 0;
}