#include<bits/stdc++.h>

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define fst first
#define snd second
#define pb push_back
#define ALL(x) x.begin(),x.end()
#define EPS (1e-9)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

bool LT(double a,double b) { return !equals(a,b) && a < b; }
bool LTE(double a,double b) { return equals(a,b) || a < b; }

const string YES = "";
const string NO  = "";

typedef long long ll;
typedef pair<int,int> ii;

#define MAX 300010
int H,W,M;
int ys[MAX], xs[MAX];
#define PX 0
#define PY 1
ll sum[2][MAX];

bool debug = 0; // narfewjafpoaw

struct Data {
  int x;
  ll sum;
  bool operator < ( const Data &d ) const {
    if( sum != d.sum ) return sum < d.sum;
    return x > d.x;
  }
};

vector<int> vec_y[MAX];

ll bf() {
  int max_x = 0, max_y = 0;
  rep(i,M) {
    max_x = max(xs[i],max_x);
    max_y = max(ys[i],max_y);
  }
  ll ans = 0;
  rep(y,max_y+1) {
    rep(x,max_x+1) {
      ll score = 0;
      rep(k,M) {
	if( xs[k] == x || ys[k] == y ) {
	  ++score;
	}
      }
      ans = max(ans,score);
    }
  }
  return ans;
}

void solve() {
  rep(i,M) {
    ++sum[PX][xs[i]];
    ++sum[PY][ys[i]];
  }
  ll ans = 0;
  rep(i,M) {
    ll score = sum[PX][xs[i]] + sum[PY][ys[i]] - 1;
    assert( score >= 0LL );
    ans = max(ans, score);
  }
  
  if( debug ) {
    cout << "med -- ans = " << ans << endl;
  }

  int maxi_y = 0;
  int maxi_x = 0;
  rep(i,M) {
    vec_y[ys[i]].pb(xs[i]);
    maxi_y = max(maxi_y,ys[i]);
    maxi_x = max(maxi_x,xs[i]);
  }

  priority_queue<Data> Q;
  rep(i,maxi_x+1) {
    if( sum[PX][i] != 0 ) {
      Q.push((Data){i, sum[PX][i]});
      if( debug ) {
	cout << "* initial X sum <- add - ( x = " << i << ", sum = " << sum[PX][i] << ")" << endl;
      }
    }
  }
  
  rep(i,maxi_y+1) {
    if( vec_y[i].size() == 0 ) continue;
    ll score =  (ll)vec_y[i].size();
    rep(j,(int)vec_y[i].size()) {
      int x = vec_y[i][j];
      --sum[PX][x];
      Q.push((Data){x, sum[PX][x]});
    }

    if( debug ) {
      cout << "* " << i << "-th:" << endl;
      cout << "  y = " << i << endl;
      cout << "  ";
      rep(j,(int)vec_y[i].size()) {
	cout << vec_y[i][j] << ", ";
      } puts("");
      cout << "  current score = " << score << endl;
      puts("--- before sum ---");
      rep(xx,maxi_x+1) {
	if( sum[PX][xx] != 0 ) {
	  cout << "  sum[PX][" << xx << "] = " << sum[PX][xx] << endl;
	}
      }
      puts("--- before sum --");
      puts("");
    }

    while( !Q.empty() ) {
      Data d = Q.top(); Q.pop();
      //cout << "  d = (d.x = " << d.x << ", d.sum = " << d.sum << ")" << endl;
      if( sum[PX][d.x] != d.sum ) continue;
      score = score + d.sum;
      Q.push(d);
      break;
    }

    if( debug ) {
      cout << "  next score = " << score << endl;
    }

    rep(j,(int)vec_y[i].size()) {
      int x = vec_y[i][j];
      ++sum[PX][x];
      if( debug ) {
	cout << "  Q <- {" << x << "," << sum[PX][x] << "}" << endl;
      }
      Q.push((Data){x, sum[PX][x]});
    }
    if( debug ) {
      puts("--- after sum ---");
      rep(xx,maxi_x+1) {
	if( sum[PX][xx] != 0 ) {
	  cout << "  sum[PX][" << xx << "] = " << sum[PX][xx] << endl;
	}
      }
      puts("--- after sum --");
      puts("");

    }
    
    ans = max(ans,score);
  }
  cout << ans << endl;
  if( debug ) {
    cout << "Answer: " << bf() << endl;
  }
}

int main() {
  if( 0 ) {
    srand((unsigned int)time(NULL));
    H = 10, W = 10;
    M = 15;
    cout << H << " " << W << " " << M << endl;
    set<ii> S;
    while( (int)S.size() < M ) {
      int x = rand() % W + 1;
      int y = rand() % H + 1;
      S.insert(ii(x,y));
    }
    for(ii p : S) {
      cout << p.snd << " " << p.fst << endl;
    }
    return 0;
  }
  cin >> H >> W >> M;
  rep(i,M) {
    cin >> ys[i] >> xs[i];
    --ys[i], --xs[i];
  }
  solve();
  return 0;
}


Measured memory_bytes: 43124