#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
 
#define ll long long
#define ld long double
 
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
 
#define err() cout<<"=================================="<<endl;
#define errA(A) for(auto i:A)   cout<<i<<" ";cout<<endl;
#define err1(a) cout<<#a<<" "<<a<<endl
#define err2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define err3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl
#define err4(a,b,c,d) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<" "<<#d<<" "<<d<<endl
 
#define pb push_back
#define all(A)  A.begin(),A.end()
#define allr(A)    A.rbegin(),A.rend()
#define ft first
#define sd second
 
#define pll pair<ll,ll>
#define V vector<ll>
#define S set<ll>
#define VV vector<V>
#define Vpll vector<pll>
 
#define endl "\n"
 
const ll logN = 20;
const ll N=100005;
const ll M = 1000000007;
const ll INF = 1e12;
#define PI 3.14159265
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
ll pow1(ll a,ll b){
    ll res=1;
    while(b>0){
        if(b&1){
        	res=(res*a)%M;
		}
        a=(a*a)%M;
        b>>=1;
    }
    return res%M;
}

// struct segtree{
//     ll x,y;
//     ll tree[4*N];

//     void build_tree(vector<ll>&v , ll ind,ll l, ll r)
//     {
//         if(l==r)
//         {
//             tree[ind]=v[l];
//             return;
//         }
//         ll mid=(l+r)/2;
//         build_tree(v,2*ind,l,mid);
//         build_tree(v,2*ind+1,mid+1,r);
//         tree[ind]=max(tree[2*ind],tree[2*ind+1]);
//     }

//     ll query(ll ind, ll l, ll r)
//     {
//         // cout<<l<<" "<<r<<" "<<endl;
//         if(x>r || y<l)return -LLONG_MAX;
//         if(l>=x && r<=y)return tree[ind];
//         ll mid=(l+r)/2;
//         return max(query(2*ind,l,mid),query(2*ind+1,mid+1,r));
//     }
// }obj;

int main()
{
    fast;

    #ifndef ONLINE_JUDGE
    freopen("../input.txt", "r", stdin);
    freopen("../output.txt", "w", stdout);
    #endif
    
    ll T=1;
//     cin>>T;
    while(T--)
    {
        ll n,m;
        cin>>n>>m;
        ll t;
        cin>>t;
        V row(n,0),col(m,0);
        Vpll tmp;
        while(t--)
        {
            ll x,y;
            cin>>x>>y;
            x--;
            y--;
            tmp.pb(make_pair(x,y));
            row[x]++;col[y]++;
        }

        set<ll> h1,v1;
        ll mx_h=*max_element(all(row));
        ll mx_v=*max_element(all(col));

        if(mx_h==0 && mx_v==0)
        {
            cout<<"0"<<endl;
            continue;
        }

        rep(i,0,n)
        {
            if(row[i]==mx_h)
            h1.insert(i);
        }
        
        rep(i,0,m)
        {
            if(col[i]==mx_v)
            {
                v1.insert(i);
            }
        }
        ll ans=mx_h+mx_v;
        
        map<ll,V>tmp1;

        for(auto it:tmp)
        {
            ll x=it.first,y=it.second;
            if(h1.find(x)!=h1.end())
            {
                tmp1[x].pb(y);
            }
        }

        for(auto it:tmp1)
        {
            ll k=0;
            for(auto cols : it.second)
            {
                if(v1.find(cols)!=v1.end())
                {
                    k++;
                }
            }
            if(k<v1.size())
            {
                cout<<ans<<endl;
                return 0;
            }
        }

        // for(auto it:tmp)
        // {
        //     ll x=it.first,y=it.second;
        //     if(h1.find(x)!=h1.end())
        //     {
        //         tmp1[x].pb(y);
        //     }
        // }

        // for(auto it:tmp1)
        // {
        //     ll k=0;
        //     for(auto cols : it.second)
        //     {
        //         if(v1.find(cols)==v1.end())
        //         {
        //             k++;
        //         }
        //     }
        //     if(k<v1.size())
        //     {
        //         cout<<ans<<endl;
        //         return 0;
        //     }
        // }

        cout<<ans-1<<endl;

    }

}

Measured memory_bytes: 73472