#include <iostream>
#include <vector>
using namespace std;

int A, B, E, match[5009]; vector<int> G[5009];
bool used[5009];

bool dfs(int pos) {
	used[pos] = true;
	for (int i = 0; i < G[pos].size(); i++) {
		if (match[G[pos][i]] < 0 || (used[match[G[pos][i]]] == false && dfs(match[G[pos][i]]) == true)) {
			match[pos] = G[pos][i];
			match[G[pos][i]] = pos;
			return true;
		}
	}
	return false;
}

int main() {
	cin >> A >> B >> E;
	for (int i = 0; i < E; i++) {
		int p1, p2; cin >> p1 >> p2;
		G[p1].push_back(p2 + A);
		G[p2 + A].push_back(p1);
	}
	for (int i = 0; i < A + B; i++) match[i] = -1;

	int cnt = 0;
	for (int i = 0; i < A + B; i++) {
		if (match[i] >= 0) continue;
		for (int j = 0; j < A + B; j++) used[j] = false;
		bool I = dfs(i);
		if (I == true) cnt++;
	}
	cout << cnt << endl;
	return 0;
}
