#include<bits/stdc++.h>

#define ll long long
#define ld long double
#define FOR(x,y) for(ll i=x;i<=y;i++)
#define pb(x) push_back(x)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define matrix(x) vector<vector<x>>
#define vss vector<string>
#define PI (2*acos(0.0))
#define sqr(x) ((x)*(x))
#define sf(a)   scanf("%d",&a)
#define sfl(a)  scanf("%lld",&a)
#define sff(a,b)    scanf("%d %d",&a,&b)
#define sffl(a,b)   scanf("%lld %lld",&a,&b)
#define sfff(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define sfffl(a,b,c)    scanf("%lld %lld %lld",&a,&b,&c)
#define ms(a,b) memset(a, b, sizeof(a))
#define ff  first
#define ss  second
#define lcm(a, b)   ((a)*((b)/__gcd(a,b)))
#define all(a)  a.begin(),a.end()
#define readfile freopen("input.txt","r",stdin);
#define writefile freopen("output.txt","w",stdout);
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define gap " "
#define mx 104
#define inf (ll)1e9
#define WHITE 1
#define GRAY 2
#define BLACK 3
#define EMPTY_VALUE -1
#define mod 1000000007
#define MOD(a,b) (a%b + b)%b

using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif


int main()
{
    //fastio
    ll h,w,m,r,c;
    sfffl(h,w,m);
    vll row(h+5,0);
    vll col(w+5,0);
    ll cnt = 0;
    map<pair<ll,ll>,ll> store;
    ll maxrow=0,maxcol=0;
    for(ll i=0;i<m;i++)
    {
        sffl(r,c);
        store[{r,c}]++;
        row[r]++;
        col[c]++;
        maxrow = max(maxrow,row[r]);
        maxcol = max(maxcol,col[c]);
    }
    vll maxRows,maxCols;
    for(ll i=0;i<=h;i++)
    {
        if(row[i]==maxrow) maxRows.pb(i);
    }
    for(ll i=0;i<=w;i++) 
    {
        if(col[i]==maxcol) maxCols.pb(i);
    }
    ll checker = 0;
    ll rowsSize = maxRows.size(),colSize = maxCols.size();
    for(ll i=0;i<rowsSize;i++)
    {
        for(ll j=0;j<colSize;j++)
        {
            if(store[{maxRows[i],maxCols[j]}]==0)
            {
                checker == 1;
                printf("%lld\n",maxrow+maxcol);
                return 0;
                //break;
            }
        }
    }
    if(checker==0) printf("%lld\n",maxrow+maxcol-1);
    
    /*for(ll i=0;i<=h;i++)
    {
        if(row[i]>=maxrow)
        {
            if(row[i]>maxrow)
            {
                rowindex = i;
                maxrow = row[i];
            }
            else if(row[i]==maxrow && (i!=1 && i!=h))
            {
                rowindex = i;
            }
        
        } 
    }
    for(ll i=0;i<=w;i++)
    {
        if(col[i]>=maxcol)
        {
            if(col[i]>maxcol)
            {
                maxcol = col[i];
                colindex = i;
            }
            else if(col[i]==maxcol && (i!=1 && i!=w))
            {
                colindex = i;
            }
            
        }
    }*/
    //ll checker = 0,sz = store.size();
    /*for(ll i=0;i<sz;i++)
    {
        if(store[i].first==rowindex && store[i].second==colindex)
        {
            checker = 1;
            break;
        }
    }*/

    //if(store[{rowindex,colindex}]>0) cout<<maxrow+maxcol-1<<endl;
    //else cout<<maxrow+maxcol<<endl;

    return 0;
}

Measured memory_bytes: 35076