#include <bits/stdc++.h>
using namespace std;
int __OneWan_2024 = [](){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
return 0;
}();
vector<int> adj[505];
int vis[505], mat[505];
int tag;
bool check(int x) {
if (vis[x] == tag) return false;
vis[x] = tag;
for (auto &to : adj[x]) {
if ((mat[to] == 0) || check(mat[to])) {
mat[to] = x;
return true;
}
}
return false;
}
int main() {
int n, m, e;
cin >> n >> m >> e;
for (int i = 0 ; i < e ; i++) {
int u, v;
cin >> u >> v;
adj[u].push_back(v);
}
int cnt = 0;
for (int i = 1 ; i <= n ; i++) {
if (check(tag = i)) {
cnt++;
}
}
cout << cnt;
return 0;
}