//题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=2063
//类似上一个的最简单的匈牙利算法用法..直接用模版的.
#include<stdio.h>
#include<stdlib.h>#include<iostream>
#include<math.h>
#include<string.h>
#include<vector>
using namespace std;
const int inf = 0x3f3f3f;
const int MN = 510;
int m,k,n,ppx[MN],ppy[MN];
bool map[MN][MN],mk[MN];
bool path(int x)
{
for(int i = 1 ; i <= n ; i++)
{
if(map[x][i] && !mk[i])
{
mk[i] = 1;
if(ppy[i] == -1 || path(i))
{
ppx[x] = i;
ppy[i] = x;
return 1;
}
}
}
return 0;
}
int Maxmatch()
{
int mm;
int sum=0;
memset(ppx,-1,sizeof(ppx));
memset(ppy,-1,sizeof(ppy));
for(mm=1;mm<=m;mm++)
{
if(ppx[mm]==-1)
{
memset(mk,0,sizeof(mk));
if(path(mm)==1)
sum++;
}
}
return sum;
}
int main()
{
while(scanf("%d",&k) && k != 0)
{
scanf("%d%d",&m,&n);
int x,y;
memset(map,0,sizeof(map));
for(int i = 1 ; i <= k ; i++)
{
scanf("%d%d",&x,&y);
map[x][y] = 1;
}
int ans = Maxmatch();
printf("%d\n",ans);
}
}