#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define pb push_back
#define md ((st + nd) >> 1)
#define lc (1 + (idx << 1))
#define rc (2 + (idx << 1))
const int N = 100005;
vector <int> v[N];
int edg[N];
int main() {
int n, m, k;
scanf("%d %d %d", &n, &m, &k);
int res = 0;
for (int i = 0; i < k; i++) {
int x, y;
scanf("%d %d", &x, &y);
v[y].pb(x);
edg[x]++;
}
for (int i = 1; i <= n; i++) {
res += edg[i] > 0;
}
for (int i = 1; i <= m; i++) {
int sum = res + 1;
for (int y : v[i]) {
sum -= edg[y] == 1;
}
res = min(res, sum);
}
printf("%d", res);
return 0;
}
Copy