#include <bits/stdc++.h>
#define ll long long
#define PB push_back
#define MP make_pair
#define S second
#define F first
#define PI pair<int , int>
#define REP(i, n) for(int i=0;i<(int)(n);++i)
#define FOR(i,l,h) for(int i=(int)(l);i<=(int)(h);++i)
#define FORD(i,h,l) for(int i=(int)(h);i>=(int)(l);--i)

//#define max(a,b) a>b?a:b
//#define min(a,b) a>b?b:a

ll gcd(ll a, ll b) { return !b ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }

#define dump(x)  cerr << #x << " = " << (x) << endl
#define ALL(t) (t).begin(),(t).end()

using namespace std;

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

int sum() { return 0; }

template<typename T, typename... Args>
T sum(T a, Args... args) { return a + sum(args...); }

/*
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

	string s;cin>>s;
	ll sum = 0;
	for (int i = 0; i < s.size(); ++i)
	{
		sum += (s[i] - '0');
	}
	if(sum % 9 == 0) cout<<"Yes\n";
	else cout<<"No\n";
    return 0;
}
*/

/*
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int n;std::cin >> n;
	std::vector<int> v(n);
	REP(i,n)cin>>v[i];
	int prev= v[0];
	ll sum =0;
	for (int i = 1; i < n; ++i)
	{
		if(v[i] < v[i-1]){
			sum += (v[i-1] - v[i]);
			v[i] = v[i-1];
		}
	}
	std::cout << sum << "\n";
	return 0;
}
*/


bool sortbysec(pair<int,int> &p1 , pair<int ,int> &p2){
	return p1.second < p2.second;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int n,w,m;std::cin >> n>>w>>m;
	std::vector<pair<int ,int> > vp(m);
	for (int i = 0; i < m; ++i)
	{
		int a,b;
		cin>>a>>b;
		vp[i]= {a,b};
	}
	int ans1 , ans2;
	{
	sort(ALL(vp));
	ll mx1 =0 , mx2 =0;
	int cnt =1, i = 0;
	int f1 ,f2;
	while (i < m)
	{
		int j = i+1;
		cnt =1;
		while (vp[i].first == vp[j].first && j<m)
		{
			cnt++;
			j++;
		}
		//mx1 = max(mx1 , cnt);
		if(mx1 < cnt){
			mx1 = cnt;
			f1 = vp[i].first;
		}
		i = j;
	}
	sort(vp.begin() , vp.end() , sortbysec);
	i =0;
	cnt =1;
	while (i<m)
	{
		int j =i+1;
		cnt = 1;
		while ((vp[i].second == vp[j].second) && (vp[j].first != f1) && (vp[i].first != f1) && j<m)
		{
			cnt++;
			j++;
		}
		//mx1 = max(mx1 , cnt);
		if(vp[i].first == f1) cnt -= 1;
		if(mx2 <= cnt ){
			mx2 = cnt;
			f2 = vp[i].second;
		}
		i = j;
	}
	ans1 = mx1+mx2;
	}
	{
		sort(vp.begin() , vp.end() , sortbysec);
		ll mx1 =0 , mx2 =0;
		int cnt =1, i = 0;
		int f1 ,f2;
		while (i < m)
		{
			int j = i+1;
			cnt =1;
			while (vp[i].second == vp[j].second)
			{
				cnt++;
				j++;
			}
			//mx1 = max(mx1 , cnt);
			if(mx1 < cnt){
				mx1 = cnt;
				f1 = vp[i].second;
			}
			i = j;
		}
		sort(ALL(vp));
		i =0;
		cnt =1;
		while (i<m)
		{
			int j =i+1;
			cnt = 1;
			while ((vp[i].F == vp[j].F) && (vp[j].S != f1) && (vp[i].S != f1)&& j <m)
			{
				cnt++;
				j++;
			}
			//mx1 = max(mx1 , cnt);
			if(vp[i].S == f1) cnt -= 1;
			if(mx2 < cnt ){
				mx2 = cnt;
				f2 = vp[i].F;
			}
			i = j;
		}
		ans2 = mx1+mx2;
	}

	cout<<max(ans1 , ans2);
	return 0;
}


Measured memory_bytes: 5564