1 #include<cstdio>
2 #include<iostream>
3 #include<cstring>
4
5 using namespace std;
6
7 int k, n, m;
8 int match[505], vis[505], g[505][505];
9
10 inline int dfs(int u){
11 for(int i = 1; i <= m; i++){
12 if(g[u][i] && !vis[i]){
13 vis[i] = 1;
14 if(!match[i] || dfs(match[i])){
15 match[i] = u;
16 return 1;
17 }
18 }
19 }
20 return 0;
21 }
22
23 inline int hungary(){
24 memset(match, 0, sizeof(match));
25 int ans = 0;
26 for(int i = 1; i <= n; i++){
27 memset(vis, 0, sizeof(vis));
28 if(dfs(i)) ans++;
29 }
30 return ans;
31 }
32
33 int main(){
34 while(~scanf("%d%d%d", &k, &n, &m) && k != 0){
35 memset(g, 0, sizeof(g));
36 for(int i = 1; i <= k; i++){
37 int a, b;
38 scanf("%d%d", &a, &b);
39 g[a][b] = 1;
40 }
41 printf("%d
", hungary());
42 }
43 return 0;
44 }