#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <functional>
#include <list>
#include <numeric>
#include <math.h>
#include <cstdlib>
#include <queue>
#include <iterator>
#include <limits>
#include <string>
#include <sstream>
#include <iomanip>
#include <bitset>
#include <mutex>
#include <condition_variable>
#include <atomic>
#include <stack>
#include <memory>
#include <deque>
#include <string_view>
#include <random>
#include <chrono>
#include <cstring>

using namespace std;

static int my_speed_up = []() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); return 0; }();
using ll = long long; using ull = unsigned long long;
template<class T> using v = vector<T>;
template<class T> using vv = vector<vector<T>>;
template<class T> using vvv = vector<vector<vector<T>>>;
template<class T> using vvvv = vector<vector<vector<vector<T>>>>;
#define for_b(i, b) for (int i = 0; i < (b); ++i)
#define for_ab(i, a, b) for (int i = a; i < (b); ++i)
#define what_is(x) cout << #x << " = " << x << endl;
#define what_are(x,y) cout << #x << " = " << x << ", " << #y << " = " << y << endl;
#define pad(x) for_b(i, x) cout << "  ";
#define show_1d(___x) cout << #___x << " = "; for (auto& ___num : ___x) cout << ___num << ", "; cout << endl;
#define show_2d(___x) cout << #___x << endl; for (auto& ___row : ___x) { for (auto ___num : ___row) cout << ___num << ", "; cout << endl; }
#define show_3d(___x) cout << #___x << endl; for (auto& ___row : ___x) { for (auto& ___row2 : ___row) { for (auto ___num : ___row2) cout << ___num << ", "; cout << endl; }cout << endl; }

vv<int> d4 = {{1,0},{-1,0},{0,1},{0,-1}};
vv<int> d8 = {{1,0},{-1,0},{0,1},{0,-1},{1,1},{1,-1},{-1,1},{-1,-1}};
bool is_valid_pos(const vv<int>& tb, int x, int y) {
    return x >= 0 && x < tb.size() && y >= 0 && y < tb[0].size();
}


int main()
{
    int H, W, M;
    cin >> H >> W >> M;
    
    unordered_map<int, int> row_cnt;
    unordered_map<int, int> col_cnt;
    
    vv<int> tars;
    for_b(i,M)
    {
        v<int> cur (2);
        cin >> cur[0] >> cur[1];
        
        ++row_cnt[cur[0]];
        ++col_cnt[cur[1]];
        tars.push_back(move(cur));
    }
    
    int max_row = 0;
    int max_row_cnt = -1;
    
    for (auto [k,val] : row_cnt)
    {
        if (val > max_row_cnt)
        {
            max_row = k;
            max_row_cnt = val;
        }
    }
    
    int res = 0;
    unordered_map<int, int> cur_col_cnt;
    int cur_col_max = 0;
    
    for (auto& tar : tars)
    {
        if (tar[0] != max_row)
        {
            ++cur_col_cnt[tar[1]];
            cur_col_max = max(cur_col_max, cur_col_cnt[tar[1]]);
        }
    }
    res = max(res, cur_col_max + max_row_cnt);
    
    
    int max_col = 0;
    int max_col_cnt = -1;
    for (auto [k,val] : col_cnt)
    {
        if (val > max_col_cnt)
        {
            max_col = k;
            max_col_cnt = val;
        }
    }
    
    unordered_map<int, int> cur_row_cnt;
    int cur_row_max = 0;
    
    for (auto& tar : tars)
    {
        if (tar[1] != max_col)
        {
            ++cur_row_cnt[tar[0]];
            cur_row_max = max(cur_row_max, cur_row_cnt[tar[0]]);
        }
    }
    res = max(res, cur_row_max + max_col_cnt);
    cout << res << endl;
    
    // 1 0 1 
    // 0 1 0
    // 0 0 0
    
    // 1, 1, 0
    // 0, 0, 0
    // 1, 0, 1
    
    
    return 0;
}


Measured memory_bytes: 74152