from random import randint
import numpy as np
from numba import njit


#@njit
def f(h,w,m,ins):
    yp = np.zeros((h,2),dtype=np.int)
    xp = np.zeros((w,2),dtype=np.int)
    yp[:,1] = np.arange(h)
    xp[:,1] = np.arange(w)
    ans = 0
    s = set()
    for hi,wi in ins:
        s.add((hi-1,wi-1))
        yp[hi-1,0] += 1
        xp[wi-1,0] += 1
    ypm = yp[:,0].max()
    xpm = xp[:,0].max()
    yps = yp[yp[:,0] == ypm][:,1]
    xps = xp[xp[:,0] == xpm][:,1]
    #y = yp[yps]
    for ypsi in yps:
        for xpsi in xps:
            a = yp[ypsi,0]+xp[xpsi,0]
            if (ypsi,xpsi) in s:
                a -= 1
                ans = max(ans,a)
            else:
                return a
    return ans


if False:
    while True:
        h,w = randint(1,10**5*3),randint(1,10**5*3)
        m = randint(1,min(h*w,10**5*3))
        ins = [(randint(1,h),randint(1,w)) for i in range(m)]
        ans1 = f1(h,w,m,ins)
        ans2 = f2(h,w,m,ins)
        if ans1 != ans2:
            print("!!!!")
            print(h,w,m)
            print(ins)
else:
    h,w,m = map(int,input().split())
    ans = f(h,w,m,[tuple(map(int,input().split())) for i in range(m)])
    print(ans) from random import randint import numpy as np numpy from numba import njit def f(h,w,m,ins):
    yp = np.zeros((h,2),dtype=np.int)
    xp = np.zeros((w,2),dtype=np.int)
    yp[:,1] = np.arange(h)
    xp[:,1] = np.arange(w)
    ans = 0
    s = set()
    for hi,wi in ins:
        s.add((hi-1,wi-1))
        yp[hi-1,0] += 1
        xp[wi-1,0] += 1
    ypm = yp[:,0].max()
    xpm = xp[:,0].max()
    yps = yp[yp[:,0] == ypm][:,1]
    xps = xp[xp[:,0] == xpm][:,1]
    #y = yp[yps]
    for ypsi in yps:
        for xpsi in xps:
            a = yp[ypsi,0]+xp[xpsi,0]
            if (ypsi,xpsi) in s:
                a -= 1
                ans = max(ans,a)
            else:
                return a
    return ans f yp = np.zeros((h,2),dtype=np.int) yp np.zeros((h,2),dtype=np.int) np.zeros np zeros (h,2) h 2 dtype=np.int dtype np.int np int xp = np.zeros((w,2),dtype=np.int) xp np.zeros((w,2),dtype=np.int) np.zeros np zeros (w,2) w 2 dtype=np.int dtype np.int np int yp[:,1] = np.arange(h) yp[:,1] yp : np.arange(h) np.arange np arange h xp[:,1] = np.arange(w) xp[:,1] xp : np.arange(w) np.arange np arange w ans = 0 ans 0 s = set() s set() set for hi,wi in ins:
        s.add((hi-1,wi-1))
        yp[hi-1,0] += 1
        xp[wi-1,0] += 1
     hi wi ins s.add((hi-1,wi-1)) s.add s add (hi-1,wi-1) hi-1 hi 1 wi-1 wi 1 yp[hi-1,0] += 1 yp[hi-1,0] yp hi-1 hi 1 1 xp[wi-1,0] += 1 xp[wi-1,0] xp wi-1 wi 1 1 ypm = yp[:,0].max() ypm yp[:,0].max() [:,0].max [:,0] yp : max xpm = xp[:,0].max() xpm xp[:,0].max() [:,0].max [:,0] xp : max yps = yp[yp[:,0] == ypm][:,1] yps yp[yp[:,0] == ypm][:,1] [yp[:,0] == ypm] yp yp[:,0] == ypm yp[:,0] yp : ypm : xps = xp[xp[:,0] == xpm][:,1] xps xp[xp[:,0] == xpm][:,1] [xp[:,0] == xpm] xp xp[:,0] == xpm xp[:,0] xp : xpm : for ypsi in yps:
        for xpsi in xps:
            a = yp[ypsi,0]+xp[xpsi,0]
            if (ypsi,xpsi) in s:
                a -= 1
                ans = max(ans,a)
            else:
                return a
     ypsi yps for xpsi in xps:
            a = yp[ypsi,0]+xp[xpsi,0]
            if (ypsi,xpsi) in s:
                a -= 1
                ans = max(ans,a)
            else:
                return a
     xpsi xps a = yp[ypsi,0]+xp[xpsi,0] a yp[ypsi,0]+xp[xpsi,0] yp[ypsi,0] yp ypsi xp[xpsi,0] xp xpsi if (ypsi,xpsi) in s:
                a -= 1
                ans = max(ans,a)
            else:
                return a
     (ypsi,xpsi) in s (ypsi,xpsi) ypsi xpsi s a -= 1 a 1 ans = max(ans,a) ans max(ans,a) max ans a return a a return ans ans h h w w m m ins ins if False:
    while True:
        h,w = randint(1,10**5*3),randint(1,10**5*3)
        m = randint(1,min(h*w,10**5*3))
        ins = [(randint(1,h),randint(1,w)) for i in range(m)]
        ans1 = f1(h,w,m,ins)
        ans2 = f2(h,w,m,ins)
        if ans1 != ans2:
            print("!!!!")
            print(h,w,m)
            print(ins)
else:
    h,w,m = map(int,input().split())
    ans = f(h,w,m,[tuple(map(int,input().split())) for i in range(m)])
    print(ans) False while True:
        h,w = randint(1,10**5*3),randint(1,10**5*3)
        m = randint(1,min(h*w,10**5*3))
        ins = [(randint(1,h),randint(1,w)) for i in range(m)]
        ans1 = f1(h,w,m,ins)
        ans2 = f2(h,w,m,ins)
        if ans1 != ans2:
            print("!!!!")
            print(h,w,m)
            print(ins) True h,w = randint(1,10**5*3),randint(1,10**5*3) h randint(1,10**5*3) randint 1 10**5*3 10**5 10 5 3 w randint(1,10**5*3) randint 1 10**5*3 10**5 10 5 3 m = randint(1,min(h*w,10**5*3)) m randint(1,min(h*w,10**5*3)) randint 1 min(h*w,10**5*3) min h*w h w 10**5*3 10**5 10 5 3 (randint(1,h),randint(1,w)) for i in range(m) for i in range(m) i range(m) range m for i in range(m) (randint(1,h),randint(1,w)) randint(1,h) randint 1 h randint(1,w) randint 1 w ins = [(randint(1,h),randint(1,w)) for i in range(m)] ins [(randint(1,h),randint(1,w)) for i in range(m)] ans1 = f1(h,w,m,ins) ans1 f1(h,w,m,ins) f1 h w m ins ans2 = f2(h,w,m,ins) ans2 f2(h,w,m,ins) f2 h w m ins if ans1 != ans2:
            print("!!!!")
            print(h,w,m)
            print(ins) ans1 != ans2 ans1 ans2 print("!!!!") print "!!!!" print(h,w,m) print h w m print(ins) print ins h,w,m = map(int,input().split()) h map(int,input().split()) map int input().split() ().split () input split w m tuple(map(int,input().split())) for i in range(m) for i in range(m) i range(m) range m for i in range(m) tuple(map(int,input().split())) tuple map(int,input().split()) map int input().split() ().split () input split ans = f(h,w,m,[tuple(map(int,input().split())) for i in range(m)]) ans f(h,w,m,[tuple(map(int,input().split())) for i in range(m)]) f h w m [tuple(map(int,input().split())) for i in range(m)] print(ans) print ans ans2 = f2(h,w,m,ins) f2(h,w,m,ins) ans2 ans = f(h,w,m,[tuple(map(int,input().split())) for i in range(m)]) f(h,w,m,[tuple(map(int,input().split())) for i in range(m)]) ans ins = [(randint(1,h),randint(1,w)) for i in range(m)] [(randint(1,h),randint(1,w)) for i in range(m)] ins ans1 = f1(h,w,m,ins) f1(h,w,m,ins) ans1 def f(h,w,m,ins):
    yp = np.zeros((h,2),dtype=np.int)
    xp = np.zeros((w,2),dtype=np.int)
    yp[:,1] = np.arange(h)
    xp[:,1] = np.arange(w)
    ans = 0
    s = set()
    for hi,wi in ins:
        s.add((hi-1,wi-1))
        yp[hi-1,0] += 1
        xp[wi-1,0] += 1
    ypm = yp[:,0].max()
    xpm = xp[:,0].max()
    yps = yp[yp[:,0] == ypm][:,1]
    xps = xp[xp[:,0] == xpm][:,1]
    #y = yp[yps]
    for ypsi in yps:
        for xpsi in xps:
            a = yp[ypsi,0]+xp[xpsi,0]
            if (ypsi,xpsi) in s:
                a -= 1
                ans = max(ans,a)
            else:
                return a
    return ans def f(h,w,m,ins):
    yp = np.zeros((h,2),dtype=np.int)
    xp = np.zeros((w,2),dtype=np.int)
    yp[:,1] = np.arange(h)
    xp[:,1] = np.arange(w)
    ans = 0
    s = set()
    for hi,wi in ins:
        s.add((hi-1,wi-1))
        yp[hi-1,0] += 1
        xp[wi-1,0] += 1
    ypm = yp[:,0].max()
    xpm = xp[:,0].max()
    yps = yp[yp[:,0] == ypm][:,1]
    xps = xp[xp[:,0] == xpm][:,1]
    #y = yp[yps]
    for ypsi in yps:
        for xpsi in xps:
            a = yp[ypsi,0]+xp[xpsi,0]
            if (ypsi,xpsi) in s:
                a -= 1
                ans = max(ans,a)
            else:
                return a
    return ans f m = randint(1,min(h*w,10**5*3)) randint(1,min(h*w,10**5*3)) m h,w = randint(1,10**5*3),randint(1,10**5*3) randint(1,10**5*3) h h,w,m = map(int,input().split()) map(int,input().split()) h w,m = map(int,input().split()) map(int,input().split()) w m = map(int,input().split()) map(int,input().split()) m w = randint(1,10**5*3),randint(1,10**5*3) randint(1,10**5*3) w
from random import randint
import numpy as np
from numba import njit


#@njit
def f(h,w,m,ins):
    yp = np.zeros((h,2),dtype=np.int)
    xp = np.zeros((w,2),dtype=np.int)
    yp[:,1] = np.arange(h)
    xp[:,1] = np.arange(w)
    ans = 0
    s = set()
    for hi,wi in ins:
        s.add((hi-1,wi-1))
        yp[hi-1,0] += 1
        xp[wi-1,0] += 1
    ypm = yp[:,0].max()
    xpm = xp[:,0].max()
    yps = yp[yp[:,0] == ypm][:,1]
    xps = xp[xp[:,0] == xpm][:,1]
    #y = yp[yps]
    for ypsi in yps:
        for xpsi in xps:
            a = yp[ypsi,0]+xp[xpsi,0]
            if (ypsi,xpsi) in s:
                a -= 1
                ans = max(ans,a)
            else:
                return a
    return ans


if False:
    while True:
        h,w = randint(1,10**5*3),randint(1,10**5*3)
        m = randint(1,min(h*w,10**5*3))
        ins = [(randint(1,h),randint(1,w)) for i in range(m)]
        ans1 = f1(h,w,m,ins)
        ans2 = f2(h,w,m,ins)
        if ans1 != ans2:
            print("!!!!")
            print(h,w,m)
            print(ins)
else:
    h,w,m = map(int,input().split())
    ans = f(h,w,m,[tuple(map(int,input().split())) for i in range(m)])
    print(ans)
