program ABC176E
    implicit none
    integer(8)::H,W,M,hi,wi,i,j,hcount=1,wcount=1,hmmax,wmmax,flg=0
    integer(8),allocatable::G(:,:),Hm(:),Wm(:),Hmax(:),Wmax(:)
    read*,H,W,M
    allocate(G(W,H))
    allocate(Hm(H))
    allocate(Wm(W))
    allocate(Hmax(H))
    allocate(Wmax(W))
    G=0
    Hm=0
    Wm=0
    Hmax=0
    Wmax=0
    do i=1,M
        read*,hi,wi
        Hm(hi)=Hm(hi)+1
        Wm(wi)=Wm(wi)+1
        G(wi,hi)=1
    end do

    hmmax=maxval(Hm)
    wmmax=maxval(Wm)

    do i=1,H
        if(Hm(i)==hmmax)then
            Hmax(hcount)=i
            hcount=hcount+1
        end if
    end do

    do i=1,W
        if(Wm(i)==wmmax)then
            Wmax(wcount)=i
            wcount=wcount+1
        end if
    end do

    do i=1,hcount-1
        do j=1,wcount-1
            if(G(Wmax(j),Hmax(i))==0)then
                flg=1
                exit
            end if
        end do
        if(flg==1)exit
    end do
    if(flg==1)then
        print'(i0)',maxval(Hm)+maxval(Wm)
    else
        print'(i0)',maxval(Hm)+maxval(Wm)-1
    end if
end program ABC176E