#include<stdio.h> #include<string.h> #include<vector> #include<algorithm> #include<iostream> #define N 1005 using namespace std; vector <int> v[N]; int link[N]; int vis[N]; int n, m, k; int find( int u ) { for( int i = 0; i < v[u].size(); i++ ) { int to = v[u][i]; if( !vis[to] ) { vis[to] = 1; if( !link[to] || find( link[to] ) ) { link[to] = u; return 1; } } } return 0; } int main() { while(~scanf("%d", &k) && k) { scanf("%d%d", &n, &m); for( int i = 1; i<= n; i++ ) v[i].clear(); int a, b; while(k--) { scanf("%d%d", &a, &b); v[a].push_back(b); } memset(link, 0, sizeof(link)); int ans = 0; for( int i = 1; i <= n; i++ ) { memset(vis, 0, sizeof(vis)); ans += find(i); } printf("%d\n", ans); } return 0; }