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

tate1 = []
yoko1 = []

max_tate = 0
max_yoko = 0

for i in 0...m
  temp = gets.split.map(&:to_i)
  temp[0]-=1
  temp[1]-=1
  tate[temp[0]] += 1
  if max_tate<tate[temp[0]]
    max_tate = tate[temp[0]]
    tate1 = [temp[0]]
  elsif max_tate==tate[temp[0]]
    tate1.push(temp[0])
  end
  yoko[temp[1]] += 1
  if max_yoko<yoko[temp[0]]
    max_yoko = yoko[temp[0]]
    yoko1 = [temp[0]]
  elsif max_yoko==yoko[temp[0]]
    yoko1.push(temp[0])
  end
  z[temp[0]].push temp[1]
end

for i in tate1
  for j in yoko1
    if !z[i].include?(j)
      puts max_tate+max_yoko
      return
    end
  end
end
puts max_tate+max_yoko-1
