h, w, m = gets.split.map(&:to_i)

r = Array.new(h+1,0)
c = Array.new(w+1,0)
d = Array.new(h+1) {Array.new(w+1,0)}
m.times do
    a, b = gets.split.map(&:to_i)
    r[a] += 1
    c[b] += 1
    d[a][b] += 1
end

x = (1..h).max_by{|i| r[i]}
y = (1..w).max_by{|j| c[j] - d[x][j]}
a = r[x] + c[y] - d[x][y]

y = (1..w).max_by{|j| c[j]}
x = (1..h).max_by{|i| r[i] - d[i][y]}
p [a, r[x] + c[y] - d[x][y]].max