//2020年4月17日現在

#include<stdio.h>
#include<cmath>
#include<math.h>
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<complex>
#include<queue>
#include<set>
#include<utility>
#include<iomanip>
#include<limits>
#include<thread>
#include<map>
#include<stack>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<tuple>
#include <cstdio>

using namespace std;


template <class... A>
void prints() { cout << "\n"; }
template <class... A>
void prints_rest() { cout << "\n"; }
template <class T, class... A>
void prints_rest(const T &first, const A &... rest) { cout << " " << first; prints_rest(rest...); }
template <class T, class... A>
void prints(const T &first, const A &... rest) { cout << first; prints_rest(rest...); }
template <class T, class... A>
void printd(const T &first, const A &... rest) { cout << fixed << setprecision(15) << first; prints_rest(rest...); }


namespace {
	// printElems(&a[0], &a[n]);　みたいな感じで使う。
	void printElems(const int* begin, const int* end)
	{
		for (const int* p = begin; p != end; ++p) {
			cout << *p << ' ';
		}
		cout << endl;
	}
}

#define rep(i,n) for(ll i=0; i<n; i++)
#define rep1(i,n) for(ll i=1; i<n+1; i++)
#define repr(i,n) for(ll i=n-1; i>=0; i--)
#define repr1(i,n) for(ll i=n; i>0; i--)
#define FOR(i,j,n) for(ll i=j; i < n; i++)
#define souatari(i,j,n) rep1(i,n-1)rep(j,i)
#define souatari1(i,j,n) for(ll i=2; i<n+1; i++)rep1(j,i-1)
#define mp make_pair
#define F first
#define S second
#define elif else if

typedef long long ll;
typedef vector<int>  vi;
typedef vector<vi>  vvi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef array<ll,3> arr3;
typedef long double D;


const ll llinf =  numeric_limits<ll>::max();
const ll _llinf = numeric_limits<ll>::lowest();
const int inf = numeric_limits<int>::max();
const int _inf = numeric_limits<int>::lowest();
const double dinf = numeric_limits<double>::infinity();
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const ll BIG = 1LL<<60;
const string yes = "Yes";
const string no = "No";

//----------------------------------------------
/*

//RMQ<int> segtree(200005);みたいな感じ
template <typename T>
struct RMQ {
	const T INF = numeric_limits<T>::max();
	int n;		 // 葉の数
	vector<T> dat; // 完全二分木の配列
	RMQ(int n_) : n(), dat(n_ * 4, INF) { // 葉の数は 2^x の形
		int x = 1;
		while (n_ > x) {
			x *= 2;
		}
		n = x;
	}

	void update(int i, T x) {
		i += n - 1;
		dat[i] = x;
		while (i > 0) {
			i = (i - 1) / 2;  // parent
			dat[i] = min(dat[i * 2 + 1], dat[i * 2 + 2]);
		}
	}

	// the minimum element of [a,b)
	T query(int a, int b) { return query_sub(a, b, 0, 0, n); }
	T query_sub(int a, int b, int k, int l, int r) {
		if (r <= a || b <= l) {
			return INF;
		} else if (a <= l && r <= b) {
			return dat[k];
		} else {
			T vl = query_sub(a, b, k * 2 + 1, l, (l + r) / 2);
			T vr = query_sub(a, b, k * 2 + 2, (l + r) / 2, r);
			return min(vl, vr);
		}
	}
};*/
//RMQ<pii> xtree(300005);
//RMQ<pii> ytree(300005);
set<int> xlist[300005];
set<int> ylist[300005];
int xsum[300005];
int ysum[300005];


int main(){
	int h,w,m;
	cin >> h >> w >> m;
	priority_queue<arr3> qx;
	priority_queue<arr3> qy;



	rep(i,m){
		int htmp,wtmp;
		cin >> htmp >> wtmp;
		xlist[wtmp].insert(htmp);
		ylist[htmp].insert(wtmp);
		xsum[wtmp]++;
		ysum[htmp]++;
	}

	rep1(i,h){
		qy.push({ysum[i],1,i});
	}
	rep1(i,w){
		qx.push({xsum[i],0,i});
	}
	vi xmax;
	int xm = qx.top()[0];
	while(!qx.empty()){
		if(qx.top()[0]!=xm){
			break;
		}

		xmax.push_back(qx.top()[2]);
		qx.pop();
	}
	bool flag = false;

	int ym = qy.top()[0];

	while(!qy.empty() && !flag){
		if(qy.top()[0]!=ym){
			break;
		}
		arr3 tmp = qy.top();
		qy.pop();
		for(int x : xmax){
			int it = ylist[tmp[2]].count(x);
			if(it==0){flag = true;break;}
		}

	}
	if(flag){prints(ym+xm);}
	else{prints(ym+xm-1);}

















	return 0;


}




Measured memory_bytes: 87284