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

using vec2 = pair<int, int>;
#define X first
#define Y second

int main()
{
    int H, W, M;
    cin >> H >> W >> M;

    vector<vec2> bs(M);
    vector<int> xs(W + 1, 0);
    vector<int> ys(H + 1, 0);

    int xmax = 0, ymax = 0;
    for (auto& b : bs)
    {
        cin >> b.Y >> b.X;
        xmax = max(xmax, ++xs[b.X]);
        ymax = max(ymax, ++ys[b.Y]);
    }

    int xn = 0, yn = 0;
    for (const auto& x: xs) { if (x == xmax) { ++xn; } }
    for (const auto& y: ys) { if (y == ymax) { ++yn; } }

    int zn = 0;
    for (const auto& b : bs) { if (xs[b.X] == xmax && ys[b.Y] == ymax) { ++zn; } }

    cout << xmax + ymax - (zn == xn * yn ? 1 : 0) << endl;

    return 0;
}