#include <bits//stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(obj) begin(obj), end(obj)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
int main(void) {
    int h, w, m,a,b,mh=0,mw=0,cnt=0,hc; cin >> h >> w >> m;
    vector<pair<int, int>> v(m);vector<int> H(h, 0), W(w, 0);
    rep(i, m) {
        cin >> a >> b;v[i] = { --a,--b };
        chmax(mh,++H[a]);chmax(mw, ++W[b]);
    }rep(i, m) {
        if (H[v[i].first] == mh && W[v[i].second] == mw) cnt++;
    }hc = count(ALL(H), mh) * count(ALL(W), mw);
     cout << mh + mw - (hc == cnt) << endl;
}