import sys

def main():
    h, w, m = map(int,input().split())
    bomb = [tuple(map(lambda x: int(x)-1, input().split())) for _ in range(m)]
    x = [0] * h
    y = [0] * w

    for h,w in bomb:
        x[h] +=1
        y[w] +=1

    maxX = max(x)
    maxY = max(y)

    r = [h for h,x in enumerate(x) if x == maxX]
    c = [w for w,y in enumerate(y) if y == maxY]

    bomb = set(bomb)
    
    for ri in r:
        for ci in c:
            if (ri,ci) not in bomb:
                print(maxX + maxY)
                sys.exit()
    print(maxX + maxY -1)
    
main() import sys sys def main():
    h, w, m = map(int,input().split())
    bomb = [tuple(map(lambda x: int(x)-1, input().split())) for _ in range(m)]
    x = [0] * h
    y = [0] * w

    for h,w in bomb:
        x[h] +=1
        y[w] +=1

    maxX = max(x)
    maxY = max(y)

    r = [h for h,x in enumerate(x) if x == maxX]
    c = [w for w,y in enumerate(y) if y == maxY]

    bomb = set(bomb)
    
    for ri in r:
        for ci in c:
            if (ri,ci) not in bomb:
                print(maxX + maxY)
                sys.exit()
    print(maxX + maxY -1)
     main h, w, m = map(int,input().split()) h map(int,input().split()) map int input().split() ().split () input split w m tuple(map(lambda x: int(x)-1, input().split())) for _ in range(m) for _ in range(m) _ range(m) range m for _ in range(m) tuple(map(lambda x: int(x)-1, input().split())) tuple map(lambda x: int(x)-1, input().split()) map lambda x: int(x)-1 int(x)-1 int(x) int x 1 x input().split() ().split () input split bomb = [tuple(map(lambda x: int(x)-1, input().split())) for _ in range(m)] bomb [tuple(map(lambda x: int(x)-1, input().split())) for _ in range(m)] x = [0] * h x [0] * h [0] 0 h y = [0] * w y [0] * w [0] 0 w for h,w in bomb:
        x[h] +=1
        y[w] +=1

     h w bomb x[h] +=1 x[h] x h 1 y[w] +=1 y[w] y w 1 maxX = max(x) maxX max(x) max x maxY = max(y) maxY max(y) max y h for h,x in enumerate(x) if x == maxX for h,x in enumerate(x) if x == maxX h x enumerate(x) enumerate x x == maxX x maxX if x == maxX h r = [h for h,x in enumerate(x) if x == maxX] r [h for h,x in enumerate(x) if x == maxX] w for w,y in enumerate(y) if y == maxY for w,y in enumerate(y) if y == maxY w y enumerate(y) enumerate y y == maxY y maxY if y == maxY w c = [w for w,y in enumerate(y) if y == maxY] c [w for w,y in enumerate(y) if y == maxY] bomb = set(bomb) bomb set(bomb) set bomb for ri in r:
        for ci in c:
            if (ri,ci) not in bomb:
                print(maxX + maxY)
                sys.exit()
     ri r for ci in c:
            if (ri,ci) not in bomb:
                print(maxX + maxY)
                sys.exit()
     ci c if (ri,ci) not in bomb:
                print(maxX + maxY)
                sys.exit()
     (ri,ci) not in bomb (ri,ci) ri ci bomb print(maxX + maxY) print maxX + maxY maxX maxY sys.exit() sys.exit sys exit print(maxX + maxY -1) print maxX + maxY -1 maxX + maxY maxX maxY 1 main() main def main():
    h, w, m = map(int,input().split())
    bomb = [tuple(map(lambda x: int(x)-1, input().split())) for _ in range(m)]
    x = [0] * h
    y = [0] * w

    for h,w in bomb:
        x[h] +=1
        y[w] +=1

    maxX = max(x)
    maxY = max(y)

    r = [h for h,x in enumerate(x) if x == maxX]
    c = [w for w,y in enumerate(y) if y == maxY]

    bomb = set(bomb)
    
    for ri in r:
        for ci in c:
            if (ri,ci) not in bomb:
                print(maxX + maxY)
                sys.exit()
    print(maxX + maxY -1)
     def main():
    h, w, m = map(int,input().split())
    bomb = [tuple(map(lambda x: int(x)-1, input().split())) for _ in range(m)]
    x = [0] * h
    y = [0] * w

    for h,w in bomb:
        x[h] +=1
        y[w] +=1

    maxX = max(x)
    maxY = max(y)

    r = [h for h,x in enumerate(x) if x == maxX]
    c = [w for w,y in enumerate(y) if y == maxY]

    bomb = set(bomb)
    
    for ri in r:
        for ci in c:
            if (ri,ci) not in bomb:
                print(maxX + maxY)
                sys.exit()
    print(maxX + maxY -1)
     main
import sys

def main():
    h, w, m = map(int,input().split())
    bomb = [tuple(map(lambda x: int(x)-1, input().split())) for _ in range(m)]
    x = [0] * h
    y = [0] * w

    for h,w in bomb:
        x[h] +=1
        y[w] +=1

    maxX = max(x)
    maxY = max(y)

    r = [h for h,x in enumerate(x) if x == maxX]
    c = [w for w,y in enumerate(y) if y == maxY]

    bomb = set(bomb)
    
    for ri in r:
        for ci in c:
            if (ri,ci) not in bomb:
                print(maxX + maxY)
                sys.exit()
    print(maxX + maxY -1)
    
main()
