//  zukonit14 - Kunal Raut

#include<bits/stdc++.h>
using namespace std;

/*/-----------------------------DEFINES----------------------------------/*/

#define ll                  long long
#define int                 long long
#define ld                  long double
#define pb                  push_back
#define mp                  make_pair
#define fi                  first
#define se                  second
#define pi                  3.1415926535
#define all(v)              v.begin(), v.end()
#define allr(v)             v.rbegin(), v.rend()
#define ms(s, n)            memset(s, n, sizeof(s))
#define prec(n)             fixed<<setprecision(n)
#define forci(p,n)          for(ll i=p;i<(ll)n;i++)
#define forcj(p,n)          for(ll j=p;j<(ll)n;j++)
#define bolt                ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define bits(a)             __builtin_popcountll(a)
#define djokovic            freopen("input00.txt", "r", stdin);freopen("output00.txt", "w", stdout);
#define inrange(i,a,b)      ((i>min(a,b)) && (i<max(a,b)))
#define sz(a)               (ll)a.size()
clock_t time_p              = clock();
void rtime()                {time_p = clock() - time_p; cout << "\nTime Taken : " << fixed << (float)(time_p) / CLOCKS_PER_SEC << "s\n";}

/*/-----------------------------INLINE FUNCTIONS----------------------------------/*/

inline ll gcd(ll a, ll b)          {if (b == 0) return a;    return gcd(b, a % b);}
inline ll lcm(ll a, ll b)          {return (a / gcd(a, b) * b);}
inline ll ncr(ll n, ll r)          {ll res = 1; if (r > n - r)r = n - r; for (ll i = 0; i < r; i++) {  res *= n - i;  res /= i + 1; } return res;}
inline bool prime(ll n)            {ll i; for (i = 2; i <= sqrt(n); i++) {if (n % i == 0)return false;} return true;}

/*/-----------------------------TRACE FUNCTIONS----------------------------------/*/

template<class T> ostream& operator<<(ostream &os, string V) {
    os << "[ ";
    for (auto v : V) os << v << " ";
    return os << "]";
}
template<class T> ostream& operator<<(ostream &os, vector<T> V) {
    os << "[ ";
    for (auto v : V) os << v << " ";
    return os << "]";
}
template<class T> ostream& operator<<(ostream &os, set<T> S) {
    os << "{ ";
    for (auto s : S) os << s << " ";
    return os << "}";
}
template<class T> ostream& operator<<(ostream &os, multiset<T> S) {
    os << "{ ";
    for (auto s : S) os << s << " ";
    return os << "}";
}
template<class T, class T1> ostream& operator<<(ostream &os, map<T, T1> S) {
    os << "{ ";
    for (auto s : S) os << "(" << s.first << "," << s.second << ") ";
    return os << "}";
}
template<class L, class R> ostream& operator<<(ostream &os, pair<L, R> P) {
    return os << "(" << P.first << "," << P.second << ")";
}
#define tracearr(a,n)  {cout << #a<<" : ";cout<<"[ ";for (ll i = 0; i < n; i++) cout << a[i] << " ";cout << "]\n";}
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
    cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cout.write(names, comma - names) << " : " << arg1 << " | ";
    __f(comma + 1, args...);
}
#else
#define trace(...)
#endif

/*/-----------------------------MODULAR ARITHMETIC----------------------------------/*/

const ll mod = 1e9 + 7;
inline ll add(ll x, ll y) {
    x += y;
    if (x >= mod) return x - mod;
    return x % mod;
}
inline ll sub(ll x, ll y) {
    x -= y;
    if (x < 0) return x + mod;
    return x;
}
inline ll mul(ll x, ll y) {
    return (x * 1ll * y) % mod;
}
inline ll expo(ll x, ll y) {
    ll ans = 1;
    while (y) {
        if (y & 1) ans = mul(ans, x);
        x = mul(x, x);
        y >>= 1;
    }
    return ans % mod;
}
inline ll inv(ll x) {
    return expo(x, mod - 2);
}
/*/-----------------------------CODE BEGINS----------------------------------/*/

ll rr[] = {0, 1, 1, 1, 0, -1, -1, -1};
ll cc[] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MAXN = 2e5 + 10, MAX2N = 2e3 + 10, LG = 20, INF = 2e18;
const ll N = MAXN;
ll n, m, k, x, y, z, q, a[MAXN], b[MAXN];
set<pair<ll, ll>>sy;    //freq->x,y
void solve()
{
    cin >> n >> m >> k;
    vector<pair<ll, ll>>v;
    map<ll, ll>xx, yy;
    forci(0, k)
    {
        ll x, y; cin >> x >> y;
        v.pb({x, y});
        xx[x]++;
        yy[y]++;
    }
    set<ll>fy;
    set<ll>stx;
    map<pair<ll, ll>, ll>mp;
    ll max1 = 0;
    for (ll i = 0; i < v.size(); i++)
    {
        ll x = v[i].fi, y = v[i].se;
        sy.insert({yy[y], y});
        stx.insert(x);
        mp[ {x, y}]++;
        max1 = max(max1, yy[y]);
    }
    for (ll i = 0; i < v.size(); i++)
    {
        if (yy[v[i].se] == max1)
            fy.insert(v[i].se);
    }
    ll ans = 0;
    for (auto i : stx)
    {
        ll x = i, frx, fry;
        frx = xx[x];
        fry = max1;
        ll b = 0;
        for (auto y : fy)
        {
            if (!mp[ {x, y}])
            {
                b = 1; break;
            }
        }
        if (!b)  fry--;
        ans = max(ans, frx + fry);
    }
    cout << ans;
}
signed main()
{
    bolt;

    ll t;
    t = 1;
    //cin >> t;
    for (ll i = 1; i <= t; i++)
    {
        solve();
    }
    //rtime();
}


Measured memory_bytes: 129740