#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
#define double long double
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
#define eps 1e-12 
//priority_queue<int,vector<int>, greater<int> > q2;

struct LazySegmentTree {
private:
	int n;
	vector<ll> node, lazy;
	vector<bool> lazyFlag;

public:
	LazySegmentTree(vector<int> v) {
		int sz = (int)v.size();
		n = 1; while (n < sz) n *= 2;
		node.resize(2 * n - 1);
		lazy.resize(2 * n - 1, -INF);
		lazyFlag.resize(2 * n - 1, false);

		for (int i = 0; i < sz; i++) node[i + n - 1] = v[i];
		for (int i = n - 2; i >= 0; i--) node[i] = max(node[i * 2 + 1], node[i * 2 + 2]);
	}

	void lazyEvaluate(int k, int l, int r) {
		if (lazyFlag[k]) {
			//node[k] = lazy[k];
			chmax(node[k], lazy[k]);
			if (r - l > 1) {
				//lazy[k * 2 + 1] = lazy[k * 2 + 2] = lazy[k];
				chmax(lazy[k * 2 + 1], lazy[k]);
				chmax(lazy[k * 2 + 2], lazy[k]);
				lazyFlag[k * 2 + 1] = lazyFlag[k * 2 + 2] = true;
			}
			lazyFlag[k] = false;
		}
	}

	void update(int a, int b, int x, int k = 0, int l = 0, int r = -1) {
		if (r < 0) r = n;
		lazyEvaluate(k, l, r);
		if (b <= l || r <= a) return;
		if (a <= l && r <= b) {
			//lazy[k] = x;
			chmax(lazy[k], x);
			lazyFlag[k] = true;
			lazyEvaluate(k, l, r);
		}
		else {
			update(a, b, x, 2 * k + 1, l, (l + r) / 2);
			update(a, b, x, 2 * k + 2, (l + r) / 2, r);
			node[k] = max(node[2 * k + 1], node[2 * k + 2]);
		}
	}

	int find(int a, int b, int k = 0, int l = 0, int r = -1) {
		if (r < 0) r = n;
		lazyEvaluate(k, l, r);
		if (b <= l || r <= a) return -INF;
		if (a <= l && r <= b) return node[k];
		int vl = find(a, b, 2 * k + 1, l, (l + r) / 2);
		int vr = find(a, b, 2 * k + 2, (l + r) / 2, r);
		return max(vl, vr);
	}
};
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int H, W, M; cin >> H >> W >> M;
	VI h(H), w(W);
	
	vector<VI>G(H);
	REP(i, M) {
		int x, y; cin >> x >> y;
		x--, y--;
		h[x]++;
		w[y]++;
		G[x].push_back(y);
	}
	LazySegmentTree seg(w);
	//REP(i, W)cout << seg.find(i,i + 1) << endl;
	int ans = -1;
	REP(i, H)SORT(G[i]);
	REP(i, H) {

		int tmp = h[i];
		int ma = 0;
		if (G[i].empty()) {
			tmp += seg.find(0, W);
		}
		else {
			if(G[i][0]!=0)chmax(ma, seg.find(0, G[i][0]));
		}
		REP(j, G[i].size()) {

			chmax(ma, seg.find(G[i][j], G[i][j] + 1) - 1);
			//cout << i << " " << G[i][j] << " " << seg.find(G[i][j], G[i][j] + 1) - 1 << endl;
			if (j + 1 == G[i].size()) {
				chmax(ma, seg.find(G[i][j]+1, W));
				//cout << i << " " << G[i][j] << " " << seg.find(G[i][j], W) << endl;
			}
			else {
				chmax(ma, seg.find(G[i][j]+1, G[i][j + 1]));
				//cout <<"L"<< i << " " << G[i][j] << " " << seg.find(G[i][j]+1, G[i][j+1]) << endl;
			}
		}



		chmax(ans, tmp + ma);
		//cout << tmp <<" "<< ma << endl;
	}

	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 43272