#include <bits/stdc++.h>
using namespace std;
#define ll long long
int row[300010], col[300010];
map<pair<int, int>, bool> ma;
int Mr[300010], Mc[300010];
int main() {
  int h, w, m, maxrow = 0, maxcol = 0;
  cin >> h >> w >> m;

  for (int i = 1; i <= m; i++) {
    int x, y;
    cin >> x >> y;
    ma[{x, y}] = 1;
    row[x]++;
    col[y]++;
    maxrow = max(maxrow, row[x]);
    maxcol = max(maxcol, col[y]);
  }
  for (int i = 1; i <= h; i++) if (row[i] == maxrow) Mr[++Mr[0]] = i;
  for (int i = 1; i <= w; i++) if (col[i] == maxcol) Mc[++Mc[0]] = i;
  int ans = maxrow + maxcol;
  for (int i = 1; i <= Mr[0]; i++) for (int j = 1; j <= Mc[0]; j++) {
    if (ma[{Mr[i], Mc[j]}] == 0) {
      cout << ans << endl;
      return 0;
    }
  }
  cout << --ans << endl;
  return 0;
}