/*

                         YATIN KWATRA                   _03_08_14


Let's Hoop..

------------------------------------------------

           o
 /|   o         o
 \|=--            o
    ##
                    \\
                 /   \O
                O_/   T
                T    /|
                |\  | |
 _______________|_|________

------------------------------------------------

o- - -  \o          __|
   o/   /|          vv`\
  /|     |              |
   |    / \_            |
  / \   |               |
 /  |                   |


------------------------------------------------

HOOPER_4_LYF..

*/

// AC BAKSHI RABBA

// #pragma GCC optimize "trapv"

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define FIO                     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pbds                    tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define ll                      long long
#define ld                      long double
#define ull                     unsigned long long
#define endl                    "\n"
#define fo(i,a,b)               for(int i = a; i<=b ; i++)
#define rfo(i,a,b)              for(int i = a; i>=b ; i--)
#define vii                     vector<int>
#define vll                     vector<ll>
#define pq                      priority_queue
#define uom                     unordered_map
#define all(v)                  v.begin(),v.end()
#define mp                      make_pair
#define pb                      push_back
#define pob                     pop_back
#define ff                      first
#define ss                      second
#define pii                     pair<int,int>
#define pll                     pair<ll,ll>
#define mll                     map<ll,ll>
#define mii                     map<int,int>
#define vvii                    vector<vii>
#define vvll                    vector<vll>
#define mod                     1000000007
#define MIN                     -1e9
#define pi                      3.1415926535897932384626433832795

using namespace std;
using namespace __gnu_pbds;

void INPUT()
{
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
}

/*
----------------------------------------------------------------

   -> Check For Overflows
   -> Out of Bounds
   -> Initialisations of global arrays and variables
   -> Read the Question and the sample test cases carefully
   -> Its not Always Complex, Try to simplify
   -> write it down and try to solve
   -> Have Faith in urself and in ur approach
   -> If it seems totally out of reach, switch to next :)
   -> And Come Back later, if possible ..

----------------------------------------------------------------*/

const int N = 3e5 + 5;

ll r[N], c[N];
vll col;
vll row;
bool cmp(ll a, ll b)
{
  if (c[a]^c[b]) return c[a] > c[b];
  return r[a] < r[b];
}

bool cmp1(ll a, ll b)
{
  if (r[a]^r[b]) return r[a] > r[b];
  return c[a] < c[b];
}

void solve()
{

  ll n, m, q;
  cin >> n >> m >> q;


  col.clear();
  row.clear();

  map<pll, bool>h;

  fo(i, 0, N - 1) r[i] = c[i] = 0;

  ll x, y;

  fo(i, 0, q - 1)
  {
    cin >> x >> y;
    x--, y--;

    h[mp(x, y)] = 1;

    r[x]++;
    c[y]++;

    if (c[y] == 1) col.pb(y);
    if (r[x] == 1) row.pb(x);
  }

  sort(all(col), cmp);
  sort(all(row), cmp1);

// cout << col[0] << " " << col[1] << endl;

  ll mx = 0;
  ll op1, op2, op3;

  int sz = col.size();

  fo(i, 0, N - 5)
  {
    ll cur = r[i];

    // finding the best col for it

    ll best = 0;

    op1 = col[0];


    if (h.count(mp(i, op1))) best = max(best, c[op1] - 1);
    else best = max(best, c[op1]);


    if (sz > 1)
    {
      op2 = col[1];
      if (h.count(mp(i, op2))) best = max(best, c[op2] - 1);
      else best = max(best, c[op2]);
    }
    if (sz > 2)
    {
      op2 = col[2];
      if (h.count(mp(i, op2))) best = max(best, c[op2] - 1);
      else best = max(best, c[op2]);
    }
    if (sz > 3)
    {
      op2 = col[3];
      if (h.count(mp(i, op2))) best = max(best, c[op2] - 1);
      else best = max(best, c[op2]);
    }
    if (sz > 4)
    {
      op2 = col[4];
      if (h.count(mp(i, op2))) best = max(best, c[op2] - 1);
      else best = max(best, c[op2]);
    }
    if (sz > 5)
    {
      op2 = col[5];
      if (h.count(mp(i, op2))) best = max(best, c[op2] - 1);
      else best = max(best, c[op2]);
    }
    if (sz > 6)
    {
      op2 = col[6];
      if (h.count(mp(i, op2))) best = max(best, c[op2] - 1);
      else best = max(best, c[op2]);
    }

    // cout << i << " " << best << " " << cur << endl;
    cur += best;
    mx = max(mx, cur);
  }

  sz = row.size();

  fo(i, 0, N - 5)
  {
    ll cur = c[i];

    // finding the best col for it

    ll best = 0;

    op1 = row[0];


    if (h.count(mp(op1, i))) best = max(best, r[op1] - 1);
    else best = max(best, r[op1]);


    if (sz > 1)
    {
      op2 = row[1];
      if (h.count(mp(op2 , i))) best = max(best, r[op2] - 1);
      else best = max(best, r[op2]);
    }
    if (sz > 2)
    {
      op2 = row[2];
      if (h.count(mp(op2, i))) best = max(best, r[op2] - 1);
      else best = max(best, r[op2]);
    }
    if (sz > 3)
    {
      op2 = row[3];
      if (h.count(mp(op2, i))) best = max(best, r[op2] - 1);
      else best = max(best, r[op2]);
    }
    if (sz > 4)
    {
      op2 = row[4];
      if (h.count(mp(op2, i))) best = max(best, r[op2] - 1);
      else best = max(best, r[op2]);
    }
    if (sz > 5)
    {
      op2 = row[5];
      if (h.count(mp(op2, i ))) best = max(best, r[op2] - 1);
      else best = max(best, r[op2]);
    }
    if (sz > 6)
    {
      op2 = row[6];
      if (h.count(mp(op2, i))) best = max(best, r[op2] - 1);
      else best = max(best, r[op2]);
    }

    // cout << i << " " << best << " " << cur << endl;
    cur += best;
    mx = max(mx, cur);
  }

  cout << mx << endl;
}

int main() {

  FIO
  INPUT();

  int t;
  t = 1;
// cin >> t;

  fo(i, 0, t - 1)
  {
    solve();
  }
  return 0;
}

Measured memory_bytes: 31448