#include<bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define mz make_ZT
#define fi fisrt
#define se second

using namespace std;

const int N=3e5+5;
const int M=3e5+1;

int h,w,m,aa,ab,ans;
int p[N],q[N];
map <long long,int> mp;
signed main()
{
	cin>>h>>w>>m;
	for (int i=h;i>=1;i--) p[i]=i;
	for (int j=w;j>=1;j--) q[j]=j;
	for (int i=1;i<=m;i++)
	{
		cin>>aa>>ab;
		mp[aa*M+ab]++;
		p[aa]+=M;
		q[ab]+=M;
	}
	sort(p+1,p+h+1);
	sort(q+1,q+w+1);
	for (int i=h;i>=1;i--) 
	{
		for (int j=w;j>=1;j--) 
		{
			if (mp[(p[i]%M)*M+q[j]%M]==0) {cout<<p[i]/M+q[j]/M<<endl;return 0;}
			else ans=p[i]/M+q[j]/M-1;
			if (q[j]/M>q[j-1]/M) break;
		}
		if (p[i]/M>p[i-1]/M) break;
	}
	cout<<ans<<endl;
}
