#include <bits/stdc++.h>
#include <chrono>
#include <random>
#include <sstream>
#include <string>
#define ll long long int
#define ull unsigned long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
#define loop(i,a,b) for(ll i=a;i<=b;i++)
#define vi vector <int>
#define vs vector <string>
#define vc vector <char>
#define vl vector <ll>
#define pll pair<ll,ll>
#define vpll vector <pll>
#define all(c) (c).begin(),(c).end()
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
using namespace std;
ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll modInverse(ll a){return power(a,mod-2);}
const int N=100001;
bool vis[N];
vector <int> adj[N];
ll gcd(ll a, ll b) { if (a == 0) return b; return gcd(b % a, a); } 
ll lcm(ll a, ll b){return a*b/gcd(a, b);}
// ll binaryNum[8];
// void decToBinary(ll n) 
// { 
//     // binaryNum[8];
//     rep(i,8){
//         binaryNum[i]=0;
//     }
//     int i = 0; 
//     while (n > 0) { 
//         binaryNum[i] = n % 2; 
//         n = n / 2; 
//         i++; 
//     } 
// } 
vl cnt;
vi prnt;
void dfs(ll u, ll parent){
    // vis[u]=true;
    ll a=0;
    if(adj[u].size()==1){
        // cout<<u<<' ';
        cnt[u]=1;
    }
    // cout<<u<<' ';
    for(int v:adj[u]){
        if(v!=parent){
            a++;
            prnt[v]=u;
            dfs(v, u);
            // cnt[u]+=cnt[v];
        }
    }
    if(u!=1){
        cnt[parent]+=cnt[u];
    }

}

void solve(){
    ll h,w,m;
    cin>>h>>w>>m;
    vector<pll> row(h);
    rep(i,h){
        row[i].first=0;
        row[i].second=i;
    }
    vector<pll> col(w);
    rep(i,w){
        col[i].first=0;
        col[i].second=i;
    }
    set <pll> st;
    rep(i,m){
        ll u,v;
        cin>>u>>v;
        st.insert(mp(u-1,v-1));
        row[u-1].first++;
        col[v-1].first++;
    }
    sort(all(row));
    sort(all(col));
    // rep(i,h){
    //     // cout<<row[i].first<<' '<<row[i].second<<'\n';
    // }
    // // cout<<'\n';
    // rep(i,w){
    //     // cout<<col[i].first<<' '<<col[i].second<<'\n';
    // }
    ll i = h-1;
    ll j = w-1;
    ll max=0;
    ll count=0;
    while(i>=0 && j>=0){
        // cout<<i<<' '<<j<<'\n';
        if(st.find(mp(row[i].second,col[j].second)) != st.end()){
            ll val = row[i].first+col[j].first-1;
            if(val<max){
                // cout<<row[i].second<<' '<<col[j].second<<'\n';

                break;
            }
            else{
                max = val;
                if(i!=0 && row[i-1].first==row[i].first){
                    i--;
                    // j=w-1;
                }
                else if(j!=0 && col[j-1].first==col[j].first){
                    j--;
                    i=h-1;
                }
                else{
                    // cout<<row[i].second<<' '<<col[j].second<<'\n';

                    break;
                }
            }
        }
        else{
            // cout<<row[i].second<<' '<<col[i].second<<'\n';

            ll val = row[i].first+col[j].first;
            if(val<max){
                // cout<<row[i].second<<' '<<col[j].second<<'\n';

                break;
            }
            else{
                max = val;
            }
            // cout<<row[i].second<<' '<<col[j].second<<'\n';
            break;
        }
        count++;
        if(count>m+m){
            // cout<<row[i].second<<' '<<col[j].second<<'\n';

            break;
        }
    }
    cout<<max;

}


int main()
{
    // cout<<1<<endl;
    #ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif
    
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int T=1;
    // cin>>T;
    int t=0;
    while(t++<T)
    {
        // cout<<"Case #"<<t<<":"<<' ';
        solve();
        //cout<<'\n';
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 33800