### ----------------
### ここから
### ----------------

import sys
from io import StringIO
import unittest

def yn(b):
    print("Yes" if b==1 else "No")
    return

def resolve():
    readline=sys.stdin.readline

    h,w,m=map(int, readline().rstrip().split())
    cntH=[0]*h
    cntW=[0]*w

    ys=[0]*m
    xs=[0]*m

    for i in range(m):
        y,x = map(int, readline().rstrip().split())
        y-=1
        x-=1
        cntH[y]+=1
        cntW[x]+=1
        ys[i]=y
        xs[i]=x
    maxX = max(cntW)
    maxY = max(cntH)
    cntMaxX=cntW.count(maxX)
    cntMaxY=cntH.count(maxY)
    cntMax=cntMaxX*cntMaxY

    for i in range(m):
        y=ys[i]
        x=xs[i]
        maxPtn=False
        if cntH[y]==maxY and cntW[x]==maxX:
            cntMax-=1
    if cntMax > 0:
        print(maxX+maxY)
    else:
        print(maxX+maxY-1)
    return


if 'doTest' not in globals():
    resolve()
    sys.exit()

### ----------------
### ここまで 
### ---------------- import sys sys from io import StringIO import unittest unittest def yn(b):
    print("Yes" if b==1 else "No")
    return yn print("Yes" if b==1 else "No") print "Yes" if b==1 else "No" b==1 b 1 "Yes" "No" return b b def resolve():
    readline=sys.stdin.readline

    h,w,m=map(int, readline().rstrip().split())
    cntH=[0]*h
    cntW=[0]*w

    ys=[0]*m
    xs=[0]*m

    for i in range(m):
        y,x = map(int, readline().rstrip().split())
        y-=1
        x-=1
        cntH[y]+=1
        cntW[x]+=1
        ys[i]=y
        xs[i]=x
    maxX = max(cntW)
    maxY = max(cntH)
    cntMaxX=cntW.count(maxX)
    cntMaxY=cntH.count(maxY)
    cntMax=cntMaxX*cntMaxY

    for i in range(m):
        y=ys[i]
        x=xs[i]
        maxPtn=False
        if cntH[y]==maxY and cntW[x]==maxX:
            cntMax-=1
    if cntMax > 0:
        print(maxX+maxY)
    else:
        print(maxX+maxY-1)
    return resolve readline=sys.stdin.readline readline sys.stdin.readline sys.stdin sys stdin readline h,w,m=map(int, readline().rstrip().split()) h map(int, readline().rstrip().split()) map int readline().rstrip().split() ().rstrip().split ().rstrip() ().rstrip () readline rstrip split w m cntH=[0]*h cntH [0]*h [0] 0 h cntW=[0]*w cntW [0]*w [0] 0 w ys=[0]*m ys [0]*m [0] 0 m xs=[0]*m xs [0]*m [0] 0 m for i in range(m):
        y,x = map(int, readline().rstrip().split())
        y-=1
        x-=1
        cntH[y]+=1
        cntW[x]+=1
        ys[i]=y
        xs[i]=x
     i range(m) range m y,x = map(int, readline().rstrip().split()) y map(int, readline().rstrip().split()) map int readline().rstrip().split() ().rstrip().split ().rstrip() ().rstrip () readline rstrip split x y-=1 y 1 x-=1 x 1 cntH[y]+=1 cntH[y] cntH y 1 cntW[x]+=1 cntW[x] cntW x 1 ys[i]=y ys[i] ys i y xs[i]=x xs[i] xs i x maxX = max(cntW) maxX max(cntW) max cntW maxY = max(cntH) maxY max(cntH) max cntH cntMaxX=cntW.count(maxX) cntMaxX cntW.count(maxX) cntW.count cntW count maxX cntMaxY=cntH.count(maxY) cntMaxY cntH.count(maxY) cntH.count cntH count maxY cntMax=cntMaxX*cntMaxY cntMax cntMaxX*cntMaxY cntMaxX cntMaxY for i in range(m):
        y=ys[i]
        x=xs[i]
        maxPtn=False
        if cntH[y]==maxY and cntW[x]==maxX:
            cntMax-=1
     i range(m) range m y=ys[i] y ys[i] ys i x=xs[i] x xs[i] xs i maxPtn=False maxPtn False if cntH[y]==maxY and cntW[x]==maxX:
            cntMax-=1
     cntH[y]==maxY and cntW[x]==maxX cntH[y]==maxY cntH[y] cntH y maxY cntW[x]==maxX cntW[x] cntW x maxX cntMax-=1 cntMax 1 if cntMax > 0:
        print(maxX+maxY)
    else:
        print(maxX+maxY-1)
     cntMax > 0 cntMax 0 print(maxX+maxY) print maxX+maxY maxX maxY print(maxX+maxY-1) print maxX+maxY-1 maxX+maxY maxX maxY 1 return if 'doTest' not in globals():
    resolve()
    sys.exit()

### ----------------
### ここまで 
### ---------------- 'doTest' not in globals() 'doTest' globals() globals resolve() resolve sys.exit() sys.exit sys exit def yn(b):
    print("Yes" if b==1 else "No")
    return def yn(b):
    print("Yes" if b==1 else "No")
    return yn def resolve():
    readline=sys.stdin.readline

    h,w,m=map(int, readline().rstrip().split())
    cntH=[0]*h
    cntW=[0]*w

    ys=[0]*m
    xs=[0]*m

    for i in range(m):
        y,x = map(int, readline().rstrip().split())
        y-=1
        x-=1
        cntH[y]+=1
        cntW[x]+=1
        ys[i]=y
        xs[i]=x
    maxX = max(cntW)
    maxY = max(cntH)
    cntMaxX=cntW.count(maxX)
    cntMaxY=cntH.count(maxY)
    cntMax=cntMaxX*cntMaxY

    for i in range(m):
        y=ys[i]
        x=xs[i]
        maxPtn=False
        if cntH[y]==maxY and cntW[x]==maxX:
            cntMax-=1
    if cntMax > 0:
        print(maxX+maxY)
    else:
        print(maxX+maxY-1)
    return def resolve():
    readline=sys.stdin.readline

    h,w,m=map(int, readline().rstrip().split())
    cntH=[0]*h
    cntW=[0]*w

    ys=[0]*m
    xs=[0]*m

    for i in range(m):
        y,x = map(int, readline().rstrip().split())
        y-=1
        x-=1
        cntH[y]+=1
        cntW[x]+=1
        ys[i]=y
        xs[i]=x
    maxX = max(cntW)
    maxY = max(cntH)
    cntMaxX=cntW.count(maxX)
    cntMaxY=cntH.count(maxY)
    cntMax=cntMaxX*cntMaxY

    for i in range(m):
        y=ys[i]
        x=xs[i]
        maxPtn=False
        if cntH[y]==maxY and cntW[x]==maxX:
            cntMax-=1
    if cntMax > 0:
        print(maxX+maxY)
    else:
        print(maxX+maxY-1)
    return resolve
### ----------------
### ここから
### ----------------

import sys
from io import StringIO
import unittest

def yn(b):
    print("Yes" if b==1 else "No")
    return

def resolve():
    readline=sys.stdin.readline

    h,w,m=map(int, readline().rstrip().split())
    cntH=[0]*h
    cntW=[0]*w

    ys=[0]*m
    xs=[0]*m

    for i in range(m):
        y,x = map(int, readline().rstrip().split())
        y-=1
        x-=1
        cntH[y]+=1
        cntW[x]+=1
        ys[i]=y
        xs[i]=x
    maxX = max(cntW)
    maxY = max(cntH)
    cntMaxX=cntW.count(maxX)
    cntMaxY=cntH.count(maxY)
    cntMax=cntMaxX*cntMaxY

    for i in range(m):
        y=ys[i]
        x=xs[i]
        maxPtn=False
        if cntH[y]==maxY and cntW[x]==maxX:
            cntMax-=1
    if cntMax > 0:
        print(maxX+maxY)
    else:
        print(maxX+maxY-1)
    return


if 'doTest' not in globals():
    resolve()
    sys.exit()

### ----------------
### ここまで 
### ----------------