#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
#define endl '\n'


template <typename A, typename B>
string to_string(pair<A, B> p);
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
 
string to_string(const string& s) {
  return '"' + s + '"';
}
 
string to_string(const char c) {
  return string(1,c);
}

string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
 
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (int i = int(N)-1; i >= 0; --i) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
 
void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
 
#ifdef COMPETITIVE_PROGRAMMING_LOCAL
#define dbg(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define dbg(...) if(0){}
#endif

 
class SegTree {
  constexpr static int DEFAULT = 0;
  int Combine(int l, int r) { return l + r; }

  vector<int> seg_tree;
  int n = 0;

 public:

  SegTree(int _n) : n(_n) {
    //seg_tree.resize(4*n);
    seg_tree.resize(4*n, DEFAULT);
  }

  int Query(int l, int r, int tl, int tr, int v) {
    if (l > r) return DEFAULT;
    if (l == tl && r == tr) return seg_tree[v];
    int tm = tl + (tr - tl) / 2;
    return Combine(Query(l, min(r, tm), tl, tm, v*2), 
                   Query(max(l, tm+1), r, tm+1, tr, v*2+1));
  }

  int Query(int l, int r) {
    return Query(l, r, 0, n-1, 1);
  }

  void Update(int pos, int new_val, int tl, int tr, int v) {
    if (tl == tr) {
      seg_tree[v] = new_val;
      return;
    }

    int tm = tl + (tr - tl) / 2;
    if (pos <= tm) {
      Update(pos, new_val, tl, tm, v*2);
    } else {
      Update(pos, new_val, tm+1, tr, v*2+1);
    }
    seg_tree[v] = Combine(seg_tree[v*2], seg_tree[v*2+1]);
  }

  void Update(int pos, int new_val) {
    int old_val = Query(pos,pos);
    Update(pos, old_val + new_val, 0, n-1, 1);
  }
};

int main() {
  ios::sync_with_stdio(0); cin.tie(0);
 
  ll H,W,M;
  cin >> H >> W >> M;
  map<int,set<int>> pts;
  map<int,int> xs,ys;
  for (int i = 0; i < M; ++i) {
    ll y,x;
    cin >> y >> x;
    --y,--x;
    pts[y].insert(x);
    ++ys[y];
    ++xs[x];
  }
  ll max_y = 0, max_x = 0;
  set<int> max_y_pos, max_x_pos;
  for (auto& [y,c] : ys) {
    if (c > max_y) {
      max_y_pos.clear();
      max_y_pos.emplace(y);
      max_y = c;
    } else if (c == max_y) {
      max_y_pos.emplace(y);
    }
  }
  SegTree stree(max(H,W)+10);
//  dbg(max_y_pos);
  
  for (auto& y : max_y_pos) {
    for (auto x : pts[y]) {
//      dbg(y,x);
      stree.Update(x, 1);
//      dbg(x,stree.Query(x,x));
    }
  }

  for (auto& [x,c] : xs) {
    if (c > max_x) {
      max_x_pos.clear();
      max_x_pos.emplace(x);
      max_x = c;
    } else if (c == max_x) {
      max_x_pos.emplace(x);
    }
  }
//  dbg(max_x_pos);

  
  ll max_bomb_poss_repeat = max_y + max_x;
  bool found = false;
  for (auto& x : max_x_pos) {
    if (stree.Query(x,x) != max_y_pos.size()) {
//      dbg(x, max_y_pos.size(), stree.Query(x,x));
      found = true;
      break;
    }
  }

  if (!found) --max_bomb_poss_repeat;
  
  

  cout << max_bomb_poss_repeat << endl;
}


Measured memory_bytes: 106420