#include<iostream>
#include<map>
using namespace std;

int main(){
  int h,w,m; cin>>h>>w>>m;
  int bombh[m],bombw[m];
  map<int,int> counth,countw;
  for(int i=0;i<m;i++){
    cin>>bombh[i]>>bombw[i]; bombh[i]--; bombw[i]--;
    counth[bombh[i]]++; countw[bombw[i]]++;
  }
  int hmax=0,wmax=0;
  for(auto p:counth){
    hmax=max(hmax,p.second);
  }
  for(auto p:countw){
    wmax=max(wmax,p.second);
  }
  int ans=hmax+wmax-1;
  cout<<ans;
  int acmaxhcount=0,acmaxwcount=0;
  vector<int> acmaxh,acmaxw;
  for(auto p:counth){
    if(p.second==hmax){
      acmaxhcount++;
      acmaxh.push_back(p.first);
    }
  }
  for(auto p:countw){
    if(p.second==wmax){
      acmaxwcount++;
      acmaxw.push_back(p.first);
    }
  }
}