constint N = 1010, M = 50010; int n, m, e; int idx, head[N], ver[M], nxt[M];
voidAdd(int u, int v) { ver[++idx] = v; nxt[idx] = head[u]; head[u] = idx; }
int match[N]; std::bitset<N> vis; boolCheck(int u) { for (int i = head[u]; i; i = nxt[i]) { int v = ver[i]; if (vis[v]) continue; vis[v] = true; if (!match[v] || Check(match[v])) { match[v] = u; returntrue; } } returnfalse; }
intmain() { scanf("%d%d%d", &n, &m, &e); for (int i = 1; i <= e; i++) { int u, v; scanf("%d%d", &u, &v); Add(u, v); } int ans = 0; for (int i = 1; i <= n; i++) { vis.reset(); if (Check(i)) ans++; } printf("%d\n", ans); return0; }