#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <iomanip>
#include <fstream>
#include <stack>

using namespace std;
 
#define ll long long
typedef unsigned long long ull;
typedef long double ld;

#define pii         pair<ll ,ll >
#define vi          vector<ll >
#define vii         vector<pii>
#define mi          map<ll ,ll >
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define pb          push_back
#define hell        1000000007 
#define rep(i,a,b)  for(ll int i=a;i<b;i++)
#define take        rep(i,0,n) cin>>v[i];
#define MAXN        200005


#define allr(c) (c).rbegin(),(c).rend()
int mod = 998244353;
const int inf = 1034567891;
const long long LL_INF = 1234567890123456789ll;
#define PI 3.14159265
#define endl '\n'
#define F first
#define S second
#define debug(x) cout << #x << " = " << x << endl;
#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 
#define out(container) for (auto it : container) cout << it << " "; cout << endl;
 
 
template < typename T > T GCD(T a, T b)            { ll t; while(a) { t = a; a = b % a; b = t; } return b; }
template < typename T > string toString(T a)       { return to_string(a); }
template < typename T > void toInt(string s, T &x) { stringstream str(s); str >> x;}
inline int add(long long x, long long y){ x += y; if(x >= mod) x -= mod; return x;}
inline int sub(ll x, ll y){ x -= y; if(x < 0) x += mod; return x;}
inline int mul(ll x, ll y){ return (x * 1ll * y) % mod;}
inline ll powr(ll a, ll b){
  int x = 1 % mod;
  while(b){
    if(b & 1) x = mul(x, a);
    a = mul(a, a);
    b >>= 1;
  }
  return x;
}
inline long long inv(long long a){ return powr(a, mod - 2);}
ll Powb(ll b,ll n,ll m)
{
    if(n==0) return 1LL;
    if(n==1) return b;
    ll temp = Powb(b,n/2,m);
    if(n%2==0){return (temp*temp)%m;}
    else{return (b*((temp*temp)%m))%m;}
}
ll n,m;

	

void solve()
{

	cin>>n>>m;
	ll t;
	cin>>t;
	mi mr;
	mi mc;
	mii b;
	ll g=0;
	ll h=0;
	for(ll i=0;i<t;i++)
	{
		ll x,y;
		cin>>x>>y;
		mr[x]++;
		mc[y]++;
		b[{x,y}]=1;
		g=max(g,mr[x]);
		h=max(h,mc[y]);
		
		
	}
	if(t==0)
	{
		cout<<0<<endl;
	}
	vi r;
	vi c;
	for(auto x:mr)
	{
		if(x.S==g)
		{
			r.pb(x.F);
		}
	}
	for(auto y:mc)
	{
		if(y.S==h)
		{
			c.pb(y.F);
		}
	}
	
	for(auto x:r)
	{
		for(auto y:c)
		{
			if(b[{x,y}]==0)
			{
				cout<<g+h<<endl;
				return;
			}
			else if(g+h-1==n+m-1)
			{
				cout<<g+h-1<<endl;
				return;
			}
		}
	}
	cout<<g+h-1<<endl;
	
}
int main()
{
	ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);                                                        
      
    ll t;
        
    t=1;
   
    
  // cin>>t;
    while(t--)
    solve();
}

Measured memory_bytes: 67792