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



int main(){
  int h,w,m;
  cin >> h >> w >> m;
  vi a(h),b(w);
  vector<P> c;
  rep(i,m){
    int x,y;
    cin >> x >> y;
    a[x-1]++;b[y-1]++;
    c.push_back(make_pair(x,y));
  }
  int m1=0,m2=0,n1=0,n2=0;
  vi p(h,0),q(w,0);
  rep(i,h) m1=max(m1,a[i]);
  rep(i,h) if(m1==a[i]){p[i]++;n1++;}
  rep(i,w) m2=max(m2,b[i]);
  rep(i,w) if(m2==b[i]){q[i]++;n2++;}
  sort(c.begin(),c.end());
  //cout << n1 << n2 << "\n";
  ll ans=n1;
  ans*=n2;
  for(auto k:c){
    //cout << ans;
    if(p[k.first-1]==1 and q[k.second-1]==1) ans-= 1;
  }
  if(ans==0) cout << m1+m2-1;
  else cout << m1+m2; 
  return 0;
}