#include <bits/stdc++.h>

using namespace std;
const int maxn = 1010;

int n,m,e;
int vis[maxn][maxn];
int ask[maxn];
int cnt, ans;
int matched[maxn];

bool fid(int x) {
    for (int i = 1 ; i <= m; i++)
      if (vis[x][i]) {
        if (ask[i])
            continue;
        ask[i] = 1;
        if (!matched[i] || fid(matched[i])) {
            matched[i] = x ;
            return true;
        }
    }
    return false;
}

void match() {
    cnt = 0;
    memset(matched, 0, sizeof(matched));
    for(int i = 1; i <= n; ++i) {
        memset(ask, 0, sizeof(ask));
        if(fid(i)) {
            cnt++;
        }
    }
    ans = cnt;
}

int main()
{
    scanf("%d %d %d",&n,&m,&e);
    cnt = 0;
    for(int i = 1; i <= e; i++) {
        int x,y;
        scanf("%d %d",&x, &y);
        vis[x][y] = 1;
    }
    match();
    printf("%d\n",ans);
    return 0;
}