#include<cstdio>
#include<bitset>
#include<vector>
using namespace std;
int k,n,m;
bitset<505> vis;
int main(){
while(~scanf("%d",&k)){
if(!k)return 0;
int ans=0;
scanf("%d%d",&n,&m);
vector<vector<int>> g(n+1);
vector<int> f(m+1);
for(int i=1,x,y;i<=k;++i)scanf("%d%d",&x,&y),g[x].push_back(y);
auto ck=[&](auto self,int x)->bool{
for(auto it:g[x]){
if(!vis[it]){
vis[it]=1;
if(!f[it]||self(self,f[it])){
f[it]=x;
return true;
}
}
}
return false;
};
for(int i=1;i<=n;++i){
vis.reset();
if(ck(ck,i))ans+=1;
}
printf("%d\n",ans);
}
}