/*
    ____       ____                 _
   |  _ \ _ __|  _ \  ___ _ __   __| |_ __ ___
   | | | | '__| | | |/ _ \ '_ \ / _` | '__/ _ \ 
   | |_| | |_ | |_| |  __/ | | | (_| | | | (_) |
   |____/|_(_)|____/ \___|_| |_|\__,_|_|  \___/
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define db1(x) cout << #x << "=" << x << '\n'
#define db2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << '\n'
#define db3(x, y, z) cout << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << '\n'
#define rep(i, k, n) for (int i = k; k < n ? i < n : i > n; k < n ? i += 1 : i -= 1)
#define si(x) scanf("%d", &x)
#define sl(x) scanf("%lld", &x)
#define ss(x) scanf("%s", x)
#define pi(x) printf("%d\n", x)
#define pl(x) printf("%lld\n", x)
#define ps(x) printf("%s\n", x)
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for (auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define F first
#define S second
#define pb push_back
#define ll long long

typedef pair<int, int> pii;
typedef pair<ll, ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpii;
typedef vector<pl> vpl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int mpow(int base, int exp);
void ipgraph(int m);
void dfs(int u, int par);
const int mod = 1000000007;
const int N = 3e5, M = N, OO = 1e9 + 7;
const ll LLOO = 1e18 + 7;
//=======================

vi g[N];
int a[N],n,m;
int freqi[N];
int freqj[N];
map<pii,bool> mp;
vector<int> vec[N];
void solve()
{
    si(n);
    si(m);
    int q;
    si(q);
    while(q--)
    {
		int x,y;
		si(x);
		si(y);
		x--;
		y--;
		mp[{x,y}] = 1;
		freqi[x]++;
		freqj[y]++;
		vec[x].pb(y);
	}
	set<pii> stj;
	rep(i,0,m)
	{
		stj.insert({-freqj[i],i});
	}
	int ans = 0;
	rep(i,0,n)
	{
		int j = (*stj.begin()).S;
		if (!mp[{i,j}])
		{
			ans = max(ans,freqi[i]+freqj[j]);
		}
		else
		{
			for(auto j:vec[i])
			{
				stj.erase({-freqj[j],j});
			}
			if (stj.empty())
			{
				for(auto j:vec[i])
				{
					stj.insert({-freqj[j],j});
				}
				ans = max(ans,freqi[i]+freqj[j]-1);
				continue;
			}
			int jj = (*stj.begin()).S;
			if (freqj[j] == freqj[jj])
			{
				ans = max(ans,freqi[i]+freqj[jj]);
			}
			else
			{
				ans = max(ans,freqi[i]+freqj[j]-1);
			}
			
			for(auto j:vec[i])
			{
				stj.insert({-freqj[j],j});
			}
		}
	}
	pi(ans);
}

int main()
{
    // uncomment if file :
    // freopen("in","r",stdin);
    // freopen("out","w",stdout);
    int t = 1;
    // si(t); // uncomment if testcases
    while (t--)
        solve();
    return 0;
}

int mpow(int base, int exp)
{
    base %= mod;
    int result = 1;
    while (exp > 0)
    {
        if (exp & 1)
            result = ((ll)result * base) % mod;
        base = ((ll)base * base) % mod;
        exp >>= 1;
    }
    return result;
}

void ipgraph(int n, int m)
{
    int u, v;
    while (m--)
    {
        scanf("%d %d", &u, &v);
        g[u - 1].pb(v - 1);
        g[v - 1].pb(u - 1);
    }
}

void dfs(int u, int par)
{
    for (int v : g[u])
    {
        if (v == par)
            continue;
        dfs(v, u);
    }
}


Measured memory_bytes: 81136