#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <deque>
#include <bitset>

long long mod = 1e9+7;
class Mint {
public:
  long long x;
  Mint(){}; // 引数なしでも定義できるように引数なしコンストラクタも用意しておく
  Mint(long long a){
    x = a%mod;
    while(x<0){
      x += mod;
    }
  };
  Mint& operator += (const Mint &a){
    x+=a.x;
    x%=mod;
    return *this;
  }
  Mint& operator -= (const Mint &a){
    x += (mod - a.x);
    x%=mod;
    return *this;
  }
  Mint& operator *= (const Mint &a){
    x*=a.x;
    x%=mod;
    return *this;
  }

  // a^n mod を計算する
  // Useaeg: Mint z = Mint(2).pow(n);
  Mint pow(long long n) const {
    if (n==0) return Mint(1);
    Mint y = pow(n>>1); // pow(n/2)を計算する
    y *= y;
    if (n%2==1) y *= *this;
    return y;
  }

  // a^{-1} mod を計算する
  Mint modinv(const Mint &a) const {
    return a.pow(mod-2);
  }

  Mint& operator /= (const Mint &a) {
    x *= modinv(a).x;
    x %= mod;
    return *this;
  }

  Mint operator + (Mint &a) const {
    Mint y(*this);
    y += a;
    return y;
  }

  Mint operator - (Mint &a) const {
    Mint y(*this);
    y -= a;
    return y;
  }

  Mint operator * (Mint &a) const {
    Mint y(*this);
    y *= a;
    return y;
  }

  Mint operator / (Mint &a) const {
    Mint y(*this);
    y/=a;
    return y.x;
  }

  // nCk @mod を計算する
  Mint nCk(Mint &n, const long long k) const {
    Mint y = Mint(1);
    Mint one = Mint(1);
    for (Mint i(0); (i.x)<k; i.x++){
      y *= (n-i);
      y /= (i + one);
    }
    return y;
  }

  // nPk @mod を計算する
  Mint nPk(Mint &n, long long k) const {
    Mint y(1);
    for (Mint i(0); (i.x)<k; i.x++){
      y *= (n-i);
    }
    return y;
  }
};
//bool bomb[300004][300004];
int main() {
  int H, W, M;
  std::cin >> H >> W >> M;
  int h, w;
  //std::vector<std::vector<int > > bomb(300004, std::vector<int> (300004, 0));
  std::map<int, int> row, column;
  std::vector<std::pair<int, int> > bomb;
  for (int i=0; i<M; i++) {
    std::cin >> h >> w;
    h--;
    w--;
    //bomb[h][w]++;
    bomb.push_back(std::make_pair(h, w));
    row[h]++;
    column[w]++;
  }
  int maxrow = 0;
  std::vector<int> maxrownum;
  for (auto &entry : row) {
    maxrow = std::max(maxrow, entry.second);
  }
  for (auto &entry : row) {
    if (entry.second == maxrow) {
      maxrownum.push_back(entry.first);
    }
  }

  int maxcolumn = 0;
  std::vector<int> maxcolumnnum;
  for (auto &entry : column) {
    maxcolumn = std::max(maxcolumn, entry.second);
  }
  for (auto &entry : column) {
    if (entry.second == maxcolumn) {
      maxcolumnnum.push_back(entry.first);
    }
  }
  // printf("maxrow=%d, maxcolumn=%d\n", maxrow, maxcolumn);
  long long candnum = (long long)maxrownum.size() * (long long)maxcolumnnum.size();
  if (candnum>M) {
    printf("%lld\n", (long long)maxcolumn + (long long)maxrow);
  } else {
    std::sort(bomb.begin(), bomb.end());
    for (int r : maxrownum) {
      for (int c : maxcolumnnum) {
        bool find = std::binary_search(bomb.begin(), bomb.end(), std::make_pair(r, c));
        if (!find) {
        //if (bomb[r][c]==0) {
          printf("%lld\n", (long long)maxcolumn + (long long)maxrow);
          return 0;
        }
      }
    }
    printf("%lld\n", (long long)maxcolumn + (long long)maxrow - 1);
  }
  
  return 0;
}

Measured memory_bytes: 37684