// Problem : E - Bomber
// Contest : AtCoder - AtCoder Beginner Contest 176
// URL : https://atcoder.jp/contests/abc176/tasks/abc176_e
// Memory Limit : 1024 MB
// Time Limit : 3000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;

/* DEBUGGING */
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif

/* MACROS */ 
typedef long long int ll;
 
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
 
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

typedef map<int,int> mii;

#define  ff          first
#define  ss          second
#define  pb          push_back
#define  IOS         ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define  lb          lower_bound
#define  ub          upper_bound
#define  all(x)      (x).begin(), (x).end()
#define  ps(x,y)     fixed<<setprecision(y)<<x
#define  setbit(x)   __builtin_popcountll(x)
#define  rep(i,a,b)  for(int i=a ; i<b ; ++i)
#define  repr(i,a,b) for(int i=a ; i>=b ; --i)

/* CONSTANTS */ 
#define PI 3.141592653589793
const ll MOD = 1e9 + 7;
const ll INF = 1000000000;
const ll MAX_N = 2e5 + 2;

// #define cerr if(false)cerr
/* CODE STARTS HERE */

void solve(){
    int r,c; cin >> r >> c;
    int pr; cin >> pr;
    
    vi rows(r+1,0),cols(c+1,0);
    map<pair<int,int>, int>pairs;
    
    int x,y,r_mx = -1,c_mx = -1,re = 1,ce = 1;
    vi adj_x[r+1],adj_y[c+1];
    
    while(pr--){
        cin >> x >> y;
        adj_x[x].pb(y);
        adj_y[y].pb(x);
        rows[x]++, cols[y]++;        
        pairs[{x,y}] = 1;
    }
    
    rep(i,1,r+1) sort(all(adj_x[i]));
    rep(i,1,c+1) sort(all(adj_y[i]));
        
    ll cnt = 0;
    
    for(auto it:pairs){
        x = it.ff.ff;
        y = it.ff.ss;
        
        if(rows[x] > r_mx){
            r_mx = rows[x];
            re = x;
        } else if(rows[x] == r_mx){
            auto it = lb(all(adj_x[x]),ce) - adj_x[x].begin();
            if(adj_x[x][it] != ce) re = x;
        }
        
        if(cols[y] > c_mx){
            c_mx = cols[y];
            ce = y;
        } else if(cols[y] == c_mx){
            auto it = lb(all(adj_y[y]),re) - adj_y[y].begin();
            if(adj_y[y][it] != re) ce = y;            
        }        
    }
    
    for(auto it:pairs){
        x = it.ff.ff;
        y = it.ff.ss;
        
        if(x == re) cnt++;
        else if(y == ce) cnt++;
    }
    
    cout << cnt;
}

int main(){
    IOS;
    solve();
}

Measured memory_bytes: 57044