local H,W,M=io.read("n","n","n")
local bombh={}
local bombw={}
local map={}
for i=1,math.max(H,M) do
    bombh[i]={}
    bombw[i]={}
    map[i]={}
end

local t={}
for i=1,M do
    local h,w=io.read("n","n")
    table.insert(bombh[h],w)
    table.insert(bombw[w],h)
    map[h][w]=true
    t[i]={h,w}
end

local hmax=0
local wmax=0
for i=1,M do
    local h=t[i][1]
    local w=t[i][2]
    hmax=math.max(hmax,#bombh[h])
    wmax=math.max(wmax,#bombw[w])
end

local max=hmax+wmax-1
local maxh={}
local maxw={}
for h=1,#bombh do
    if #bombh[h]==hmax then
        table.insert(maxh,h)
    end
end
for w=1,#bombw do
    if #bombw[w]==wmax then
        table.insert(maxw,w)
    end
end

for i=1,#maxh do
    local h=maxh[i]
    for j=1,#maxw do
        local w=maxw[j]
        if (map[h] and (not map[h][w])) then
            max=max+1
            print(max)
            return
        end
    end
end
print(max)