/*jai_ganeshdeva*/

#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pu push  //  adds the value to the last of the queue 
#define lld long long int
#define ins insert /// used in set to insert the values 
#define adv advance  /// used to increment the iterator
#define mp make_pair
#define fi first
#define se second
#define all(c) c.begin(),c.end()
#define PI 3.1415926
#define INF (lld)1e18
#define vl  vector<long long int >
#define vpll vector< pair<lld ,lld> >
#define vvl vector<vector<lld> > 
#define pll pair <lld,lld>
#define modA(cccc,bbbb ,p) (((cccc+bbbb)%p+p)%p)
#define modS(cccc,bbbb ,p) (((cccc-bbbb)%p+p)%p)
#define modM(cccc,bbbb ,p) ((((cccc%p)*(bbbb%p))%p+p)%p)

long long int modp(lld a,lld p,lld n)
{
    lld d[100];
    lld i,j,k,l;
    if(n==0) return 1;
    for(i=0;n>=1;i++)
    {
        d[i]=n%2;
        n/=2;
    }
    l=i;
    long long int e=1;
    if(d[0]==1) e*=(a%p);
    for(i=1;i<l;i++)
    {
        a*=a;
        a=a%p;
        if(d[i]==1) 
        {
            e*=a;
            e=e%p;
        }
    }
    return e%p;
}
lld modInverse(lld n, lld p) 
{ 
    return modp(n, p, p-2); 
}

// lld fac[500005]; 

// void getfac(lld p)
// {
//     fac[0] = 1; 
//     for (lld i=1 ; i<=500005; i++) 
//         fac[i] = fac[i-1]*i%p; 
// }    

// long long int nCrmodp(lld n, lld r,lld p) 
// { 
//    // Base case 
//    if (r==0) 
//       return 1; 
     
//     return (fac[n]* modInverse(fac[r], p) % p * 
//             modInverse(fac[n-r], p) % p) % p; 
// }



lld maxSubArraySum(vector<lld> &a, lld size) 
{ 
    lld max_so_far = INT_MIN, max_ending_here = 0; 
  
    for (lld i = 0; i < size; i++) 
    { 
        max_ending_here = max_ending_here + a[i]; 
        if (max_so_far < max_ending_here) 
            max_so_far = max_ending_here; 
  
        if (max_ending_here < 0) 
            max_ending_here = 0; 
    } 
    return max_so_far; 
} 


lld p1=1e9 + 7,p2=998244353;
lld l,r,mid,ans=0;
lld n,i,j,k,g,m;
lld x,y,n1,n2,h,z,c;
lld aa=1;
lld ss=1;

void solve()
{    
    lld h,w,m;
    cin>>h>>w>>m;
    vector<lld> v1(h+1),v2(w+1);
    vector<vector<lld> > v(h+1);
    for(i=0;i<m;i++)
    {
        cin>>x>>y;
        v[x].pb(y);
        v1[x]+=1;
        v2[y]+=1;
    }
    x = 0;
    for(i=1;i<h+1;i++)
    {
        x = max(x,v1[i]);
    }
    vector<lld> v4,v5;
    for(i=0;i<h+1;i++)
    {
        if(v1[i]==x) v4.pb(i);
    }
    lld l4=v4.size();
    ans = x;
    x=0;
    for(i=1;i<w+1;i++)
    {
        x=max(x,v2[i]);
    }
    for(i=1;i<w+1;i++)
    {
        if(v2[i]==x)
        {
            v5.pb(i);
        }
    }
    lld l5 = v5.size();
    ans+=(x-1);
    for(i=0;i<l4;i++)
    {
        sort(all(v[v4[i]]));
        lld l=  v[v4[i]].size();
        if(l5>l)
        {
            cout<<ans+1;
            return ;
        }  
        j=0;
        k=0;
        while(j<l)
        {
            if(v[v4[i]][j] == v5[k])
            {
                k+=1;
            }
            if(k>=l5) break;
            j+=1;
        }
        if(j==l && k<l5)
        {
            cout<<ans+1;
            return;
        }
    }
    cout<<ans;

}

void fun111(){
    #ifndef ONLINE_JUDGE
    // for getting input from input.
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
    #endif
    
}

int main()
{
    // fun111();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lld t=1;
    
    // cin>>t;
    // cout<<t;
    lld p1 = 1e9 + 7;
    // getfac(p1);
    //check the value by which modulo is to be taken
    // precompute();
    for(int i=0;i<t;i++)
    {
        // cout<<"Case #"<<i+1<<": ";
        solve();
        cout<<"\n";
    }
    return 0;
}


Measured memory_bytes: 32720