#include "bits/stdc++.h"
using namespace std; 

#define IOS {ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);}
#define ll long long 
multiset<ll> visisted;
// row * 1e6 + col 
const ll x=1e6;
int main(){
        IOS;
        ll n,m,x;
        cin>>n>>m>>x;
        map<ll ,ll > row;
        map<ll ,ll >col;
        for(ll i=0;i<x;i++){
                ll a,b;
                cin>>a>>b;
                ll p=a*(x) + b;
                visisted.insert(p);
                row[a]++;
                col[b]++;
        }
        
        ll mx1=0,mx2=0;
        for(auto it=row.begin() ; it!=row.end() ; it++) mx1=max(mx1,it->second);
        for(auto it=col.begin() ; it!=col.end() ; it++) mx2=max(mx2,it->second);

        set<ll> r1, c1;
        // set<ll> remr1,remc1;

        // for(ll i=1;i<=n;i++) remr1.insert(i);

        for(auto it=row.begin() ; it!=row.end() ; it++){
                if(it->second == mx1){
                        r1.insert(it->first);
                        // remr1.erase(remr1.find(it->first));
                }
        }

        // for(ll i=1;i<=m;i++) remc1.insert(i);

        for(auto it=col.begin() ; it!=col.end() ; it++){
                if(it->second == mx2){ 
                        c1.insert(it->first);         
                        // remc1.erase(remc1.find(it->first));
                }
        }

        // cout << mx1 + mx2 <<"\n";
        // for(auto it=r1.begin() ; it!= r1.end() ; it++) cout << *it<<" ";
        // cout<<"\n";

        // for(auto it=remr1.begin() ; it!= remr1.end() ; it++) cout << *it<<" ";
        // cout<<"\n";

        // for(auto it=c1.begin() ; it!= c1.end() ; it++) cout << *it<<" ";
        // cout<<"\n";

        // for(auto it=remc1.begin() ; it!= remc1.end() ; it++) cout << *it<<" ";
        // cout<<"\n";

        /*
        set<ll> rem;
        for(auto it=visisted.begin() ; it!=visisted.end() ;it++){
                ll p=*it;
                ll r=p/x;
                ll c=p%x;

                bool find1=0,find2=0;
                if((int)r1.size()){
                        auto it1=r1.find(r);
                        // if(it1 != r1.end()) find1=1;
                        if(it1 != r1.end()) rem.insert(c);
                }
                // if((int)remc1.size()){
                //         auto it2=remc1.find(c);
                //         if(it2 != remc1.end()) find2=1;
                // }

                // if(find1 && find2) ok=1;
        }

        for(auto it=remc1.begin() ; it!=remc1.end() ; it++){
                auto it1=rem.find(*it);
                if(it1 != rem.end()) ok=1;
        }

        rem.clear();

        for(auto it=visisted.begin() ; it!=visisted.end() ;it++){
                ll p=*it;
                ll r=p/x;
                ll c=p%x;

                bool find1=0,find2=0;
                if((int)c1.size()){
                        auto it1=c1.find(c);
                        // if(it1 != c1.end()) find1=1;
                        if(it1 != c1.end()) rem.insert(r);
                }
                // if((int)remr1.size()){
                //         auto it2=remr1.find(r);
                //         if(it2 != remr1.end()) find2=1;
                // }

                // if(find1 && find2) ok=1;
        }

        for(auto it=remr1.begin() ; it!=remr1.end() ; it++){
                auto it1=rem.find(*it);
                if(it1 != rem.end()) ok=1;
        }

        rem.clear();
        */
        bool ok=0;
        for(auto it1=r1.begin() ; it1 != r1.end() ; it1++){
                for(auto it2=c1.begin() ; it2 != c1.end() ; it2++){
                        // cout << *it1 <<" " << *it2 <<"\n";
                        ll xx = *it1 , yy =*it2;
                        ll num=(xx)*x + yy;
                        auto it=visisted.find(num);
                        if(it == visisted.end()){
                                ok=1;
                                break;
                        }
                }
                if(ok) break;
        }

        // cout << ok <<"\n";
        if(ok)cout << mx1 + mx2 <<"\n";
        else cout<<mx1 + mx2 -1<<"\n";
}


Measured memory_bytes: 83272