#!/usr/bin/env ruby

H, W, M = gets.chomp.split.map(&:to_i)

x = Hash.new(0)
y = Hash.new(0)

imax = -1
jmax = -1
bomb = {}

M.times do
  i, j = gets.chomp.split.map(&:to_i)

  i -= 1
  j -= 1

  x[i] += 1
  y[j] += 1

  bomb[i] ||= {}
  bomb[i][j] = true

  a = []

  a[0] = x[imax] + y[jmax]
  a[0] -= 1 if bomb[imax] && bomb[imax][jmax]

  a[1] = x[imax] + y[j]
  a[1] -= 1 if bomb[imax] && bomb[imax][j]

  a[2] = x[i] + y[jmax]
  a[2] -= 1 if bomb[i] && bomb[i][jmax]

  a[3] = x[i] + y[j]
  a[3] -= 1 if bomb[i] && bomb[i][j]

  c = a.index(a.max)

  case c
  when 1
    jmax = j
  when 2
    imax = i
  when 3
    imax = i
    jmax = j
  end
end

ans = x[imax] + y[jmax]
ans -= 1 if bomb[imax] && bomb[imax][jmax]

puts ans
