#include <iostream>
#include <vector>
#include <cmath>
#include <map>
#include <set>
#include <unordered_set>
#include <string>
#include <random>
#include <queue>


using namespace std;

// ans = a ? b : c; // to simplify: if (a) ans = b; else ans = c;
// ans += val; // to simplify: ans = ans + val; and its variants
// index = (index + 1) % n; // index++; if (index >= n) index = 0;
// index = (index + n - 1) % n; // index--; if (index < 0) index = n - 1;
// int ans = (int)((double)d + 0.5); // for rounding to nearest integer
// ans = min(ans, new_computation); // min/max shortcut
// alternative form but not used in this book: ans <?= new_computation;
// some code use short circuit && (AND) and || (OR)

typedef long long ll; // comments that are mixed in with code
typedef pair<int, int> ii; // are aligned to the right like this
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vll;
#define INF 1000000000
#define M_PI 3.14159265358979323846

void printVector2d(vector<vector<int>> a){
    for(int i=0;i<a.size();i++){
        for(int j=0;j<a[i].size();j++){
            cout<<a[i][j]<<" ";
        }
        cout<<endl;
    }
    cout<<"end"<<endl;
}

void printVector(vector<ll> a){
    for(int i=0;i<a.size();i++){
        cout<<"Total "<<i<<": "<<a[i]<<endl;
    }
}

void printVectorPair(vector<pair<int,int>> a){
    for(int i=0;i<a.size();i++){
        cout<<"Total "<<i<<": "<<a[i].first<<" "<<a[i].second<<endl;
    }
}

void printMap(map<char, int> mp){
    for(auto x:mp){
        cout<<x.first<<": "<<x.second<<endl;
    }
}

void printMapVec(map<int, vector<int>> mpV){
    for(auto x:mpV){
        cout<<x.first<<": ";
        for(auto y:x.second){
            cout<<y<<" ";
        }
        cout<<endl;
    }
}

void printQueue(queue<char> q){
    while(!q.empty()){
        cout<<q.front()<<" ";
        q.pop();
    }
    cout<<" ##### ";
}

string convertCoordToString(int h, int w){
    return to_string(h)+":"+to_string(w);
}

void solve(){
    int H,W,M,hi,wi;
//    cout<<"YO1"<<endl;
//    cout<<"YO"<<endl;
    int best_h = -1;
    int best_h_size = 0;
    int best_w = -1;
    int best_w_size = 0;
    cin>>H>>W>>M;

    vector<int> all_rows(H,0);
    vector<int> all_cols(W,0);
    vector<int> best_hi;
    vector<int> best_wi;
    set<string> all_M;

    for(int i=0;i<M;i++){
        cin>>hi>>wi;
        all_M.insert(convertCoordToString(hi,wi));
        all_rows[hi-1]++;
        all_cols[wi-1]++;
        if(all_rows[hi-1]>best_h_size) {
            best_h = hi;
            best_h_size = all_rows[hi-1];
        }
        if(all_cols[wi-1]>best_w_size) {
            best_w = wi;
            best_w_size = all_cols[wi-1];
        }
    }

    map<int, vi> sum_indices_h;
    map<int, vi> sum_indices_w;

    for(int i=0;i<all_rows.size();i++){
        // add to map
        int curr_row_sum = -1*all_rows[i];
        sum_indices_h[curr_row_sum].push_back(i);
    }
    for(int i=0;i<all_cols.size();i++){
        // add to map
        int curr_col_sum = -1*all_cols[i];
        sum_indices_w[curr_col_sum].push_back(i);
    }

    int curr_sum_h = best_h_size;
    int curr_sum_w = best_w_size;
    bool found_ans = false;
    vi ind_best_sum_h = (*sum_indices_h.begin()).second;
    vi ind_best_sum_w = (*sum_indices_w.begin()).second;
//    while(curr_sum_h==best_h_size)
    for(auto curr_ind_best_sum_h:ind_best_sum_h){
//        while(curr_sum_w==best_w_size)
        for(auto curr_ind_best_sum_w:ind_best_sum_w){
            //check if there exists this an M at this grid index
            string curr_coord_str = convertCoordToString(curr_ind_best_sum_h+1, curr_ind_best_sum_w+1);
            if(all_M.find(curr_coord_str)==all_M.end()) {
                //Then not found it
                cout << best_h_size + best_w_size << endl;
                found_ans = true;
                break;
            }
        }
        if(found_ans)
            break;
    }

    if(!found_ans)
        cout << best_h_size + best_w_size - 1<< endl;

//    string coord_str = convertCoordToString(best_h,best_w);
//    if(all_M.find(coord_str)!=all_M.end())
//        cout << best_h_size + best_w_size - 1<< endl;
//    else
//        cout << best_h_size + best_w_size << endl;
}

int main() {
    //solve();
    int T;
//    cin >> T;
    T=1;
    for (int case_num = 1; case_num <= T; case_num++) {
        solve();
    }
    return 0;
}


Measured memory_bytes: 28668