h,w,m = gets.split.map(&:to_i)
tate = Array.new(h,0)
yoko = Array.new(w,0)
z = []

for i in 0...m
  temp = gets.split.map(&:to_i)
  temp[0]-=1
  temp[1]-=1
  tate[temp[0]] += 1
  yoko[temp[1]] += 1
  z.push temp
end

tate1 = Array.new(0)
yoko1 = Array.new(0)

max_tate = tate.max
max_yoko = yoko.max

for i in 0...h
  if max_tate==tate[i]
    tate1.push i
  end
end
for i in 0...w
  if max_yoko==yoko[i]
    yoko1.push i
  end
end

kouho = Array.new(0)

for i in tate1
  for j in yoko1
    kouho.push([i,j])
  end
end

exist = -1

for k in z
  if !kouho.include?(k)
    exist = 0
    break
  end
end
puts max_tate+max_yoko+exist