#include<bits/stdc++.h>
using namespace std;
int X[300300],Y[300300];
int SumX[300300],SumY[300300];
map<pair<int,int>,bool> M;
int main()
{
	int H,W,N;
	cin>>H>>W>>N;
	for(int i=0;i<N;i++)
	{
		cin>>X[i]>>Y[i];
		X[i]--;
		Y[i]--;
		SumX[X[i]]++;
		SumY[Y[i]]++;
		M[make_pair(X[i],Y[i])]=true;
	}
	vector<int> V1,V2;
	int maxX=*max_element(SumX,SumX+H),maxY=*max_element(SumY,SumY+W);
	for(int i=0;i<H;i++)
		if(SumX[i]==maxX)
			V1.push_back(i);
	for(int i=0;i<W;i++)
		if(SumY[i]==maxY)
			V2.push_back(i);
	int len1=(int)(V1.size()),len2=(int)(V2.size());
	if(len1*len2>N)
	{
		cout<<maxX+maxY<<endl;
		return 0;
	}
	for(int i=0;i<len1;i++)
		for(int j=0;j<len2;j++)
			if(!M[make_pair(V1[i],V2[j])])
			{
				cout<<maxX+maxY<<endl;
				return 0;
			}
	cout<<maxX+maxY-1<<endl;
	return 0;
}