#include <bits/stdc++.h>
    using namespace std;
    #include <ext/pb_ds/assoc_container.hpp>
    #include <ext/pb_ds/tree_policy.hpp>
    using namespace __gnu_pbds;
     
    #define fast { ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0); }
    #define pb push_back
    #define ll long long
    #define ld long double
     
    #define vi vector<int>
    #define vl vector<long>
    #define vll vector<long long>
    #define infd LDBL_MAX
    #define f(i,a,b) for(ll i=a;i<b;i++)
    
    #define ff first
    #define ss second
   
    #define pll pair<ll,ll> 
    #define endl "\n"
    #define ALL(v) v.begin(),v.end()
    #define nl cout<<"\n";
    #define pr(x) cout<<x;
    #define pr1(x) cout<<x<<" ";
    #define pr2(x,y) cout<<x<<" "<<y;
    #define deb printf("*****************************\n");
    #define idk printf("idk idk ! \n");
    #define hi printf("hi ! \n");
    #define bye printf("bye bye ! \n");
    #define o_set(ll) tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
    #define number_of_set_bits  __builtin_popcountll  
     
  
     
     
    //const ll N=1e6+7;
    ll p=1e9+7;
    //ll fac[N];
     
// taking inpugt with help of string and " "
     /*   string s;
         getline(cin,s);
         vi a=init(s);
         if(a.size()==2)cout<<query_(a[0]+1,a[1]+1)<<endl;
         else update_(a[0]+1,a[1]+1,a[2]);
 
      */
 vi init(string s)
{
    istringstream sin(s);
    int n;
    vi arr;
    while(sin>>n)arr.push_back(n);
    return arr;
}

    ll gcd(ll a, ll b) 
    { 
        if (a == 0) 
            return b; 
        return gcd(b % a, a); 
    } 
    
    ll pow_mod_p(ll a,ll b)
    {
      a=a%p;
      ll res=1;
      while(b>0)
      {
        if(b&1) res=(res*a)%p;
        b=b>>1;
        a=(a*a)%p;
      }
      return res;
    }
     
    inline ll mod_inv(ll x)
    {
      return pow_mod_p(x,p-2);
    }
     
   
     int main() 
    {
        fast
        //#ifndef ONLINE_JUDGE
        //freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);
        //#endif // ONLINE_JUDGE
        
     
        ll ntc=1;
     //   cin>>ntc;
     
        f(i,1,ntc+1)
        {
          //cout<<"Case #"<<i<<": ";
         
         ll h,w,mn; cin>>h>>w>>mn;
         map<pair<ll,ll>,ll> m;
         ll r[300005], c[300005];
         memset(r,0,sizeof r);  memset(c,0, sizeof c);
         m.clear();
         f(i,0,mn){
             ll u,v; cin>>u>>v;
             m[{u,v}]++;
             r[u]++;
             c[v]++;
         }
      //  for(auto x: m){
    //        cout<<x.ff.ff<<" "<<x.ff.ss<<" "<<x.ss<<endl;
     //   }
        ll maxcr = 0, maxr = 0;
        ll maxcc = 0, maxc = 0;
        for(int i = 0; i < h+1; ++i){
           maxr = max(maxr,r[i]);
            
        }
         f(i,0,w+1){
             maxc = max(maxc, c[i]);
        }
        bool vis_row[300005];   bool vis_col[300005];
        f(i,0,300005){
            vis_row[i] = false;
            vis_col[i] = false;
        }
        ll row_cnt = 0; ll col_cnt = 0;
        f(i,0,h+1) {
            if(r[i] == maxr) {++row_cnt; vis_row[i] = true; }
        }
          f(i,0,w+1) {
            if(c[i] == maxc) {++col_cnt; vis_col[i] = true; }
        }
      //  cout<<maxr<<" "<<maxc<<endl;
        
        ll finalans = maxr + maxc;
      //  cout<<finalans<<endl;
        ll edges = 0;
        for(auto x: m) {
            if(vis_row[x.ff.ff] && vis_col[x.ff.ss]){
             //   cout<<"here";
        //     cout<<x.ff.ff<<" "<<x.ff.ss<<" "<<x.ss<<endl;
            ++edges;    
            }
        }
        if(edges == (row_cnt*col_cnt)) --finalans;
        cout<<finalans<<endl;
        }
        
        return 0;
    }

Measured memory_bytes: 27660