module IntPairSet = Set.Make (struct
  type t = int * int
  let compare = compare
end)

let () = Scanf.scanf "%d %d %d\n" @@ fun h w m ->
  let hs = Array.make h 0 in
  let ws = Array.make w 0 in
  let ms = IntPairSet.of_list @@ List.init m @@ fun _ -> Scanf.scanf "%d %d\n" @@ fun h w -> h - 1, w - 1 in
  IntPairSet.iter (fun (h, w) ->
    hs.(h) <- 1 + hs.(h);
    ws.(w) <- 1 + ws.(w)) ms;
  let his = Array.init h Fun.id in
  let wis = Array.init h Fun.id in
  Array.sort (fun i j -> compare hs.(j) hs.(i)) his;
  Array.sort (fun i j -> compare ws.(j) ws.(i)) wis;
  Printf.printf "%d\n" @@
  max (IntPairSet.fold (fun (h, w) -> max @@ hs.(h) + ws.(w) - 1) ms min_int) @@
  List.fold_left max min_int @@
  List.init h @@ fun i ->
    let rec solve j =
      if w <= j then min_int
      else if not (IntPairSet.mem (his.(i), wis.(j)) ms)
      then hs.(his.(i)) + ws.(wis.(j))
      else solve (j + 1) in
    solve 0
