// E - Bomber
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)

int main(){
	int H, W, M; cin>>H>>W>>M;

	set<pair<int, int>> HW;
	vector<int> sum_h(H), sum_w(W);
	int max_sum_h = 0, max_sum_w = 0;
	rep(i, M){
		int h, w; cin>>h>>w; h--, w--;
		HW.insert({h, w});
		sum_h[h]++, sum_w[w]++;
		max_sum_h = max(max_sum_h, sum_h[h]);
		max_sum_w = max(max_sum_w, sum_w[w]);
	}

	vector<int> hs, ws;
	rep(i, H) if(sum_h[i] == max_sum_h) hs.push_back(i);
	rep(i, W) if(sum_w[i] == max_sum_w) ws.push_back(i);

	int ans = max_sum_h + max_sum_w - 1;
	for(int h:hs) for(int w:ws){
		if(HW.count({h, w})) continue;
		cout<< ans + 1 <<endl;
		return 0;
	}
	cout<< ans <<endl;
}
