#include<stdio.h>
#define MX 300009
typedef struct LOC {
	int x, y;
}LOC;
LOC loc[MX];
int X[MX], Y[MX], mx_X, mx_Y, num_X, num_Y, num;
int main() {
	int h, w, m;
	scanf("%d%d%d", &h, &w, &m);
	int i;
	for (i = 1; i <= m; i++) {
		scanf("%d%d", &loc[i].x, &loc[i].y);
		++X[loc[i].x], ++Y[loc[i].y];
	}
	for (i = 1; i <= h; i++) {
		mx_X = mx_X > X[i] ? mx_X : X[i];
	}
	for (i = 1; i <= w; i++) {
		mx_Y = mx_Y > Y[i] ? mx_Y : Y[i];
	}
	for (i = 1; i <= h; i++) {
		if (X[i] == mx_X) {
			++num_X;
		}
	}
	for (i = 1; i <= w; i++) {
		if (Y[i] == mx_Y) {
			++num_Y;
		}
	}
	for (i = 1; i <= m; i++) {
		if (X[loc[i].x] == mx_X && Y[loc[i].y] == mx_Y) {
			++num;
		}
	}
	printf("%d", mx_X + mx_Y - (num == (num_X*num_Y) ? 1 : 0));
}