#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;

int main(){
  int h, w, m;
  cin >> h >> w >> m;
  set<pair<int,int>> s;
  vi ycnt(h);
  vi xcnt(w);
  int ymx = 0, xmx = 0;
  rep(i,m) {
    int y, x;
    cin >> y >> x;
    y--; x--;
    s.insert({y,x});
    ycnt[y]++;
    xcnt[x]++;
    ymx = max(ymx, ycnt[y]);
    xmx = max(xmx, xcnt[x]);
  }
  vi ym, xm;
  rep(i,h){
    if(ycnt[i] == ymx) ym.push_back(i);
  }
  rep(i,w){
    if(xcnt[i] == xmx) xm.push_back(i);
  }
  int ans = ymx + xmx -1;
  for(auto i : ym){
    for(auto j : xm){
      if(!s.count({i,j})){
        ans++;
        cout << ans << endl;
        return 0;
      }
    }
  }
  cout << ans << endl;
}
