#include<bits/stdc++.h>
using namespace std;

using ll = long long;
#define REP(i,n) for(int i = 0;i < n;i++)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define debug(arr) cout << #arr << " = " << arr << '\n'
#define debug2(a,b) cout << "[" << #a << "," << #b << "] = " << "[" << a << "," << b << "]" << '\n'

template<class T> bool chmin(T& a, T b) { if (b < a) {a = b; return true;} else return false;}
template<class T> bool chmax(T& a, T b) { if (b > a) {a = b; return true;} else return false;}
template<class T> T max_element(T[], int);
template<class T> T min_element(T[], int);
template<class T> pair<T, int> lower_bound(T arr[], int n, T val);
template<class T> pair<T, int> upper_bound(T arr[], int n, T val);
template<class T> int get_range_cnt(vector<T>& a, T lb, T ub);
template<class T> vector<pair<T, int> > runlength(vector<T> arr);
vector<pair<char, int> > runlength(string s);
template<class T> ostream &operator << (ostream&, const vector<T>&);
template<class T> ostream &operator << (ostream&, const vector<vector<T> >&);
template<class S, class T> ostream &operator << (ostream& out, const pair<S, T>& p);
template<class T> istream &operator >> (istream&, vector<T>&);

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  //cout << fixed << setprecision(20);
  //int t;cin >> t; REP(_,t) main2();

  int h, w, n; cin >> h >> w >> n;
  vector<pair<int, int>> a(n);

  REP(i, n)cin >> a[i].first >> a[i].second;
  REP(i, n) a[i].first--, a[i].second--;

  vector<pair<pair<int,int>,set<int>>> x(w),y(h);
  REP(i,w) x[i].first.second = i;
  REP(i,h) y[i].first.second = i; 
  REP(i,n){
    x[a[i].second].second.insert(a[i].first);
    y[a[i].first].second.insert(a[i].second);
  }

  REP(i,w) x[i].first.first = x[i].second.size();
  REP(i,h) y[i].first.first = y[i].second.size();

  sort(x.rbegin(),x.rend());
  sort(y.rbegin(),y.rend());
  // REP(i,h)cout << x[i].first.first << '\n';
  // cout << '\n';
  // REP(i,w)cout << y[i].first.first << '\n';
  int ans = 0;
  for(int i = 0;i < w;i++){
    if(x[i].first.first != x[0].first.first) break;
    else{
      for(int j = 0;j < h;j++){
        if(y[j].first.first != y[0].first.first) break;
        if(y[j].second.find(x[i].first.second) == y[j].second.end()){
          chmax(ans , x[i].first.first + y[j].first.first);
          break;
        }else{
          chmax(ans , x[i].first.first + y[j].first.first - 1);
        }
      }
    }
  }
  cout << ans << '\n';
  return 0;
}


/////////////////////////////////////////////////////////////////////////////////
// for debug & input
template<class T> ostream &operator << (ostream& out, const vector<T>& arr) {
  cout << "{"; for (int i = 0; i < arr.size(); i++)cout << (!i ? "" : ", ") << arr[i]; cout << "}";
  return out;
}
template<class T> ostream &operator << (ostream& out, const vector<vector<T> >& arr) {
  cout << "{\n"; for (auto& vec : arr)cout << "  " << vec << ",\n"; cout << "}";
  return out;
}
template<class S, class T> ostream &operator << (ostream& out, const pair<S, T>& p) {
  cout << "{" << p.first << "," << p.second << "}";
  return out;
}
template<class T> istream &operator >> (istream& in, vector<T>& arr) {
  for (auto& i : arr)cin >> i; return in;
}

// for arrays.
template<class T> T max_element(T arr[], int n) {
  T res = numeric_limits<T>::min(); for (int i = 0; i < n; i++) res = max(res , arr[i]); return res;
}
template<class T> T min_element(T arr[], int n) {
  T res = numeric_limits<T>::max(); for (int i = 0; i < n; i++) res = min(res , arr[i]); return res;
}
template<class T> pair<T, int> lower_bound(T arr[], int n, T val) {
  int l = 0, r = n;
  while (r - l) { int mid = (r + l) / 2; if (arr[mid] >= val) r = mid; else l = mid; }
  return make_pair(arr[r] , r);
}
template<class T> pair<T, int> upper_bound(T arr[], int n, T val) {
  int l = 0, r = n;
  while (r - l) { int mid = (r + l) / 2; if (arr[mid] > val) r = mid; else l = mid; }
  return make_pair(arr[r] , r);
}
// [lb,ub)の範囲の個数を数える
// last checked : 2020.5.8
template<class T> int get_range_cnt(vector<T>& a, T lb, T ub) {
  int n = a.size();
  int r = n - (int)(a.end() - (lower_bound(a.begin(), a.end(), ub)));
  int l = n - (int)(a.end() - (lower_bound(a.begin(), a.end(), lb)));
  return r - l;
}
template<class T> vector<pair<T, int> > runlength(vector<T> arr) {
  vector<pair<T, int> > res; int n = arr.size(); T tmp = arr[0]; int cont = 1;
  for (int i = 1; i < n; i++) {
    if (arr[i] != tmp) { res.push_back(make_pair(tmp, cont)); tmp = arr[i], cont = 1; } else cont++;
  }
  res.push_back(make_pair(tmp, cont));
  return res;
}
vector<pair<char, int> > runlength(string s) {
  vector<char> arr(s.size()); for (int i = 0; i < s.size(); i++)arr[i] = s[i];
  return runlength(arr);
}



Measured memory_bytes: 66576