#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

#include <bits/stdc++.h>
using namespace std;

pair<int,int> A[300000];

int main(){
  ll h,w,m;
  cin>>h>>w>>m;
  
  map<ll,ll> a,b;
  ll c,d;
  rep(i,m){
    cin>>c>>d;
    A[i]={c,d};
    a[c]++;
    b[d]++;
  }
  
  ll m1=0,m2=0;
  for(auto x:a){
    m1=max(m1,x.second);
  }
  for(auto x:b){
    m2=max(m2,x.second);
  }
  
  ll p=0,q=0;
  for(auto x:a){
    if(x.second==m1) p++;
  }
  for(auto x:b){
    if(x.second==m2) q++;
  }
  
  ll r=0;
  rep(i,m){
    if(a[A[i].first]==m1 && b[A[i].second]==m2) r++;
  }
  
  if(p*q==r) cout<<m1+m2-1<<endl;
  else cout<<m1+m2<<endl;

  return 0;
}