// Library
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;

// TYPEDEFS
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;

// CONSTANTS
#define SZA 0
#define SZB 0

// MACRO
#define MAX(X, Y) (((X) > (Y))? (X) : (Y))
#define MIN(X, Y) (((X) < (Y))? (X) : (Y))
#define ABS(X) (((X) > 0)? (X) : -(X))
#define YN(X) ((X)? "Yes" : "No")
#define SWAP(T, X, Y) {T t; t = X; X = Y; Y = t;}

#define F first
#define S second
#define PB push_back
#define MP make_pair


// Global Tables

//ull gPreProcess[SZA][SZB];

// Functions

void Print2DVector(vector<vector<int>>& v)
{
    ull i, j; 
    for(i = 0; i < v.size(); i++)
    {
        for(j = 0; j < v[i].size(); j++)
        {
            cout << v[i][j];
            if(j == v[i].size()-1)
            {
                cout << endl;
            }
            else
            {
                cout << " ";
            }
        }
    }
}

void PrintVector(vi& v)
{
    ull i;
    for(i = 0; i < v.size(); i++)
    {
        cout << v[i];
        if(i == v.size()-1)
        {
            cout << endl;
        }
        else
        {
            cout << " ";
        }
    }
}

void PrintArr(int* a, ull N)
{
    ull i;
    for(i = 0; i < N; i++)
    {
        cout << a[i];
        if(i == N-1)
        {
            cout << endl;
        }
        else
        {
            cout << " ";
        }
    }
}

void PreProcessTables()
{
    ull i, j;
    for(i = 0; i < SZA; i++)
    {
        for(j = 0; j < SZB; j++)
        {
            break;
        }
        break;
    }
}


void TC(int t)
{
    int H, W, M;
    cin >> H >> W >> M;
    map<pair<int, int>,bool> m;
    map<int, int> mh;
    map<int, int> mw;
    vector<pair<int, int>> vH, vW;
    int h, w, best_possible = 0, curr = -1, best_curr = 0;
    for(int i = 0; i < M; i++)
    {
        cin >> h >> w;
        if(mh.find(h) == mh.end())
        {
            mh.insert({h, 1});
        }
        else
        {
            mh[h] = mh[h] + 1;
        }
        if(mw.find(w) == mw.end())
        {
            mw.insert({w, 1});
        }
        else
        {
            mw[w] = mw[w]+1;
        }
        m.insert(make_pair(pair<int,int>(h,w),true));
    }
    for(pair<int,int> i:mh)
    {
        vH.push_back(i);
    }
    for(pair<int,int> i:mw)
    {
        vW.push_back(i);
    }
    sort(vH.begin(), vH.end(),
        [](const pair<int,int> &a, const pair<int,int> &b)->bool
        {
            return a.second > b.second;
        }
        );
    sort(vW.begin(), vW.end(), 
        [](const pair<int,int> &a, const pair<int,int> &b)->bool
        {
            return a.second > b.second;
        }
        );
    /*
    for(auto i:vH)
    {
        cout << i.first << " " << i.second << endl;
    }
    for(auto i:vW)
    {
        cout << i.first << " " << i.second << endl;
    }
    */
    h = w = 0;
    while(curr < best_possible)
    {
        best_possible = vH[h].second + vW[w].second;
        curr = best_possible - (m.find(pair<int,int>(vH[h].first,vW[w].first)) == m.end()? 0: 1);
        best_curr = max(curr, best_curr);
        if(h < vH.size()-1 && w < vW.size()-1)
        {
            if(vH[h+1].second + vW[w].second >= vH[h].second + vW[w+1].second)
            {
                h++;
            }
            else
            {
                w++;
            }
        }
        else if(h < vH.size()-1)
        {
            h++;
        }
        else if(w < vW.size()-1)
        {
            w++;
        }
        else
        {
            break;
        }
    }
    cout << best_curr << endl;
}

// Main

int main(void)
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
 
    PreProcessTables();

    int T = 1, t;
    for(t = 1; t <= T; t++)
    {
        TC(t);
    }
    return 0;
}


Measured memory_bytes: 58488