#include<bits/stdc++.h>
using namespace std;
int row[500000],col[500000];
int main()
{
	int h,w,m;
	cin>>h>>w>>m;
	int maxr = 0, maxc = 0;
	map<pair<int,int>, int> bomb;
	for (int i = 0; i < m; ++i)
	{
		int x,y;
		cin>>x>>y;
		bomb[make_pair(x,y)] = 1;

		row[x]++;
		col[y]++;
		maxr = max(maxr,row[x]);
		maxc = max(maxc,col[y]);
	}
	std::vector<int> r,c;
	for (int i = 0; i < 300001; ++i)
	{
		if(row[i]==maxr)
			r.push_back(i);
	}
	for (int i = 0; i < 300001; ++i)
	{
		if(col[i]==maxc)
			c.push_back(i);
	}
	for (int i = 0; i < r.size(); ++i)
	{
		for(int j = 0; j < c.size();j++)
		{
			int a = r[i];
			int b = c[j];
			if(bomb.find(make_pair(a,b)) == bomb.end())
			{
				printf("%d\n",maxc+maxr);
				return 0;
			}
		}
	}
	printf("%d\n",maxc+maxr-1 );


	
	return 0;
}