#include <bits/stdc++.h>

using namespace std;

int h, w, m, x[300005], y[300005], p[300005], q[300005], ans;
vector<int> A, B;
set<pair<int, int>> S;

int main() {
    scanf("%d%d%d", &h, &w, &m);
    for (int i = 1; i <= m; i++) {
        scanf("%d%d", &x[i], &y[i]);
        S.insert({x[i], y[i]});
        ++p[x[i]], ++q[y[i]];
    }
    int mx = *max_element(p + 1, p + h + 1), my = *max_element(q + 1, q + w + 1);
    for (int i = 1; i <= h; i++)
        if (mx == p[i])
            A.push_back(i);
    for (int i = 1; i <= w; i++)
        if (my == q[i])
            B.push_back(i);
    for (int i:A)
        for (int j:B)
            if (!S.count({i, j})) {
                printf("%d", mx + my);
                return 0;
            }
    printf("%d", mx + my - 1);
    return 0;
}