//use itertools::Itertools;
use std::cmp;
use std::collections::BTreeMap;
use std::collections::BTreeSet;
use std::collections::BinaryHeap;
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::VecDeque;
use std::io::Read;
use std::usize::MAX;

macro_rules! input {(source = $s:expr, $($r:tt)*) => {let mut iter = $s.split_whitespace();let mut next = || { iter.next().unwrap() };input_inner!{next, $($r)*}};($($r:tt)*) => {let stdin = std::io::stdin();let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));let mut next = move || -> String{bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect()};input_inner!{next, $($r)*}};}
macro_rules! input_inner {($next:expr) => {};($next:expr, ) => {};($next:expr, $var:ident : $t:tt $($r:tt)*) => {let $var = read_value!($next, $t);input_inner!{$next $($r)*}};}
macro_rules! read_value {($next:expr, ( $($t:tt),* )) => {( $(read_value!($next, $t)),* )};($next:expr, [ $t:tt ; $len:expr ]) => {(0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()};($next:expr, chars) => {read_value!($next, String).chars().collect::<Vec<char>>()};($next:expr, usize1) => {read_value!($next, usize) - 1};($next:expr, [ $t:tt ]) => {{let len = read_value!($next, usize);(0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()}};($next:expr, $t:ty) => {$next().parse::<$t>().expect("Parse error")};}

fn solve() {
    input! {
        h: usize,
        w:usize,
        m: usize,
        targets:[(usize1,usize1);m]
    }

    //let mut exists = vec![vec![false; w + 1]; h + 1];

    let mut h_map = HashMap::new();
    let mut h_max = 0;
    let mut w_map = HashMap::new();
    let mut w_max = 0;

    for i in 0..targets.len() {
        let bom = targets[i];
        let h_count = h_map.entry(bom.0).or_insert(0);
        let w_count = w_map.entry(bom.1).or_insert(0);
        *h_count += 1;
        *w_count += 1;
        h_max = cmp::max(h_count.clone(), h_max);
        w_max = cmp::max(w_count.clone(), w_max);
    }

    let h_max_induce: Vec<usize> = h_map
        .iter()
        .filter(|(&index, &count)| count == h_max)
        .map(|(&index, &count)| index)
        .collect();
    let w_max_induce: Vec<usize> = w_map
        .iter()
        .filter(|(&index, &count)| count == w_max)
        .map(|(&index, &count)| index)
        .collect();
    let set: HashSet<(usize, usize)> = targets.clone().into_iter().collect();

    let empty_bomb = h_max_induce
        .iter()
        .find(|&&x| {
            w_max_induce
                .iter()
                .find(|&&y| !set.contains(&(x, y)))
                .is_some()
        })
        .is_some();

    if empty_bomb {
        println!("{}", h_max + w_max);
    } else {
        println!("{}", h_max + w_max - 1);
    }
}

fn main() {
    let thd = std::thread::Builder::new().stack_size(104_857_600);
    thd.spawn(|| solve()).unwrap().join().unwrap();

    /*
    // 入力を一括で読み込む場合
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut input = buf.split_whitespace();

    // inputに対しnext()で読み込んでいく
    let q: usize = input.next().unwrap().parse().unwrap();
    */
}

const LARGE_PRIME: u64 = 1_000_000_007;

// @〜でsnippet


Measured memory_bytes: 41244