#from random import randint
import numpy as np


#@njit
def f(h,w,m,ins):
    yp = np.zeros(h,dtype=np.int)
    xp = np.zeros(w,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] += 1
        xp[wi-1] += 1
    ypm = yp[yp.argmax()]
    xpm = xp[xp.argmax()]
    yps = np.where(yp == ypm)[0].tolist()
    xps = np.where(xp == xpm)[0].tolist()
    #y = yp[yps]
    for ypsi in yps:
        for xpsi in xps:
            a = yp[ypsi]+xp[xpsi]
            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)]
        ans = f(h,w,m,ins)
        print(ans)
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) import numpy as np numpy def f(h,w,m,ins):
    yp = np.zeros(h,dtype=np.int)
    xp = np.zeros(w,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] += 1
        xp[wi-1] += 1
    ypm = yp[yp.argmax()]
    xpm = xp[xp.argmax()]
    yps = np.where(yp == ypm)[0].tolist()
    xps = np.where(xp == xpm)[0].tolist()
    #y = yp[yps]
    for ypsi in yps:
        for xpsi in xps:
            a = yp[ypsi]+xp[xpsi]
            if (ypsi,xpsi) in s:
                a -= 1
                ans = max(ans,a)
            else:
                return a
    return ans f yp = np.zeros(h,dtype=np.int) yp np.zeros(h,dtype=np.int) np.zeros np zeros h dtype=np.int dtype np.int np int xp = np.zeros(w,dtype=np.int) xp np.zeros(w,dtype=np.int) np.zeros np zeros w dtype=np.int dtype np.int np int ans = 0 ans 0 s = set() s set() set for hi,wi in ins:
        s.add((hi-1,wi-1))
        yp[hi-1] += 1
        xp[wi-1] += 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] += 1 yp[hi-1] yp hi-1 hi 1 1 xp[wi-1] += 1 xp[wi-1] xp wi-1 wi 1 1 ypm = yp[yp.argmax()] ypm yp[yp.argmax()] yp yp.argmax() yp.argmax yp argmax xpm = xp[xp.argmax()] xpm xp[xp.argmax()] xp xp.argmax() xp.argmax xp argmax yps = np.where(yp == ypm)[0].tolist() yps np.where(yp == ypm)[0].tolist() [0].tolist [0] np.where(yp == ypm) np.where np where yp == ypm yp ypm 0 tolist xps = np.where(xp == xpm)[0].tolist() xps np.where(xp == xpm)[0].tolist() [0].tolist [0] np.where(xp == xpm) np.where np where xp == xpm xp xpm 0 tolist for ypsi in yps:
        for xpsi in xps:
            a = yp[ypsi]+xp[xpsi]
            if (ypsi,xpsi) in s:
                a -= 1
                ans = max(ans,a)
            else:
                return a
     ypsi yps for xpsi in xps:
            a = yp[ypsi]+xp[xpsi]
            if (ypsi,xpsi) in s:
                a -= 1
                ans = max(ans,a)
            else:
                return a
     xpsi xps a = yp[ypsi]+xp[xpsi] a yp[ypsi]+xp[xpsi] yp[ypsi] yp ypsi xp[xpsi] 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)]
        ans = f(h,w,m,ins)
        print(ans)
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)]
        ans = f(h,w,m,ins)
        print(ans) 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)] ans = f(h,w,m,ins) ans f(h,w,m,ins) f h w m ins print(ans) print ans 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 ins = [(randint(1,h),randint(1,w)) for i in range(m)] [(randint(1,h),randint(1,w)) for i in range(m)] ins m = map(int,input().split()) map(int,input().split()) m h,w = randint(1,10**5*3),randint(1,10**5*3) randint(1,10**5*3) h m = randint(1,min(h*w,10**5*3)) randint(1,min(h*w,10**5*3)) m def f(h,w,m,ins):
    yp = np.zeros(h,dtype=np.int)
    xp = np.zeros(w,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] += 1
        xp[wi-1] += 1
    ypm = yp[yp.argmax()]
    xpm = xp[xp.argmax()]
    yps = np.where(yp == ypm)[0].tolist()
    xps = np.where(xp == xpm)[0].tolist()
    #y = yp[yps]
    for ypsi in yps:
        for xpsi in xps:
            a = yp[ypsi]+xp[xpsi]
            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,dtype=np.int)
    xp = np.zeros(w,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] += 1
        xp[wi-1] += 1
    ypm = yp[yp.argmax()]
    xpm = xp[xp.argmax()]
    yps = np.where(yp == ypm)[0].tolist()
    xps = np.where(xp == xpm)[0].tolist()
    #y = yp[yps]
    for ypsi in yps:
        for xpsi in xps:
            a = yp[ypsi]+xp[xpsi]
            if (ypsi,xpsi) in s:
                a -= 1
                ans = max(ans,a)
            else:
                return a
    return ans f h,w,m = map(int,input().split()) map(int,input().split()) h w,m = map(int,input().split()) map(int,input().split()) w w = randint(1,10**5*3),randint(1,10**5*3) randint(1,10**5*3) w ans = f(h,w,m,ins) f(h,w,m,ins) ans 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
#from random import randint
import numpy as np


#@njit
def f(h,w,m,ins):
    yp = np.zeros(h,dtype=np.int)
    xp = np.zeros(w,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] += 1
        xp[wi-1] += 1
    ypm = yp[yp.argmax()]
    xpm = xp[xp.argmax()]
    yps = np.where(yp == ypm)[0].tolist()
    xps = np.where(xp == xpm)[0].tolist()
    #y = yp[yps]
    for ypsi in yps:
        for xpsi in xps:
            a = yp[ypsi]+xp[xpsi]
            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)]
        ans = f(h,w,m,ins)
        print(ans)
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)
