//author ----> noobiesAG

#include<bits/stdc++.h>
using namespace std;

#define rep(i,a,b)         for(i=a;i<b;i++)
#define repd(i,a,b)        for(i=a;i>b;i--)
#define int                long long
#define double             long double
#define pb                 push_back
#define mp                 make_pair
#define ld                 long double
#define vi                 vector<int>
#define vvi                vector<vector<int>>
#define vpii               vector<pair<int,int>>
#define pii                pair<int,int>
#define mii                map<int,int>
#define umap               unordered_map
#define all(c)             c.begin(),c.end()
#define si(c)              (int)c.size()
#define lb                 lower_bound
#define ub                 upper_bound
#define gi                 greater<int>
#define rev                reverse
#define ff                 first
#define ss                 second
#define yes                cout << "YES" << '\n'
#define no                 cout << "NO" << '\n' 
#define ayes               cout << "Yes" << '\n'
#define ano                cout << "No" << '\n'
#define mone               cout << -1 << '\n' 
#define imp                cout << "IMPOSSIBLE" << '\n'
#define nl                 cout << '\n'
#define hello              cout << "hello" << '\n'
#define sp(x)              fixed << setprecision(x)
#define re                 return
#define p_q                priority_queue
#define FAST               ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define FIO                freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);

void dbg_out(){cerr << endl;}
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)

const double pi = 3.14159265359;
const int mod = 1000000007;
const int modc = 998244353;
const int inf = LLONG_MAX;
const int neg_inf = LLONG_MIN;

int inline power(int a, int b, int p){
    a %= p;
    int ans = 1;
    while(b>0){
        if(b & 1)
            ans = (ans*a)%p;
        a = (a*a)%p;
        b >>= 1;
    }
    return ans;
}

int mod_inv(int n, int p){
    return power(n,p-2, p);
}

bool inline isPrime(int n) {
    if (n <= 1)  return false;
    if (n <= 3)  return true;
    if (n%2 == 0 || n%3 == 0) return false;
    for (int i=5; i*i<=n; i=i+6)
        if (n%i == 0 || n%(i+2) == 0)
           return false;
    return true;
}
template<typename... T>
void W(T&&... args)
{
	((cout << sp(17) <<  args << " "), ...);
	nl;
}
template<typename... T>
void R(T&&... args)
{
	((cin >> args), ...);
}
int ston(string s) 
{
	int a = 0;
	reverse(s.begin(),s.end());
	int pow = 1;
	for(int i=0;i<s.size();i++)
	{
		a += pow*(s[i]-'0');
		pow*=10;
	}
	return a;
}
template <class T>
string to_binary(T n) 
{
	string binaryNum;
	int i = 0;
	while (n > 0) {
		binaryNum.pb((n % 2)+'0');
		n = n / 2;
		i++;
	}
	if(si(binaryNum) == 0)
		binaryNum.pb('0');
	reverse(binaryNum.begin(),binaryNum.end());
	return binaryNum;
}
int bton(string &s, int base)
{
	int ans = 0;
	int pow  = 1;
	rev(all(s));
	for(auto x : s)
	{
		if(x >= 'a' && x <= 'z')
			ans += (x - 'a' + 10)*pow;
		else
			ans += (x-'0')*pow;
		pow *= base;
	}
	return ans;
}
template<class T>
void wv(T &v)
{
	for(auto x : v)
		cout << x << " " ;
	nl;
}
template<class T>
void rv(T &v)
{
	for(int i=0;i<si(v);i++)
		cin >> v[i];
}

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
const int M = 2e5;
/*
int fact[M];
int ncr(int n, int r)
{
	int ans = fact[n];
	int denom = (fact[r]*fact[n-r])%mod;
	ans = (ans * mod_inv(denom,mod))%mod;
	return ans;
}
*/
//vector<int>v[M];

void solve()
{
	int i,j,sum = 0,prod = 1,maxl = neg_inf, minl = inf;
	int r,c,n;
	cin >> r >> c >> n;
	map<int,vi>row;
	umap<int,int,custom_hash>col;
	for(i=0;i<n;i++)
	{
		int x,y;
		cin >> x >> y;
		x--;
		y--;
		row[x].pb(y);
		col[y]++;
	}
	int ans = -1;
	umap<int,int,custom_hash>max_col;
	for(i=0;i<c;i++)
		maxl = max(maxl,col[i]);
	int cnt = 0;
	for(i=0;i<c;i++)
		if(col[i] == maxl)
		{
			max_col[i] = 1;
			cnt++;
		}
	for(auto x  : row)
	{
		int row_me = si(x.ss);
		int ayush = 1;
		int cnt1 = 0;
		for(auto y : x.ss)
		{
			if(max_col[y])
			{
				cnt1++;
			}
		}
		if(cnt1 < cnt)
			ayush = 0 ;
		ans = max(ans, row_me + maxl - ayush);
	}
	cout << ans << endl;
}
int32_t main()
{
	FAST;
	int t = 1;
	/*
	fact[0] = 1;
	for(int i = 1;i<M;i++)
		fact[i] = (i * fact[i-1])%mod;
		*/
	while(t--)
	{
		solve();
	}
} 



Measured memory_bytes: 72308