use std::collections::*; use std::io::*; use std::str::FromStr; use utils::*; pub fn main() { let i = stdin(); let mut o = Vec::new(); run(i.lock(), &mut o); stdout().write_all(&o).unwrap(); } fn run(i: R, o: &mut W) { let mut i = ReadEx::from(i); let w = i.read::(); let h = i.read::(); let n = i.read::(); let mut sk = Vec::new(); for _ in 0..n { sk.push(i.read2::()); } writeln!(o, "{}", solve(w, h, &sk)).unwrap(); } fn solve(w: usize, h: usize, sk: &[(usize, usize)]) -> usize { let mut ss = HashSet::new(); let mut ks = HashSet::new(); for sk in sk { ss.insert(sk.0); ks.insert(sk.1); } h * ss.len() + w * ks.len() - ss.len() * ks.len() - sk.len() } mod utils { use super::*; pub struct ReadEx { r: R, s: String, } macro_rules! fn_read { {$f:ident($($v:ident: $t:ident),*)} => { pub fn $f<$($t: FromStr),*>(&mut self) -> ($($t),*) { let i = &mut self.read_line().split(' '); $( let $v = next(i); )* ($($v),*) } }; } impl ReadEx { pub fn from(r: R) -> Self { ReadEx { r: r, s: String::new(), } } pub fn read_line(&mut self) -> &str { self.s.clear(); self.r.read_line(&mut self.s).unwrap(); self.s.trim() } pub fn read(&mut self) -> T { self.read_line().parse().ok().unwrap() } fn_read! { read2(v1: T1, v2: T2) } } fn next<'a, T: FromStr, I: std::iter::Iterator>(i: &mut I) -> T { i.next().unwrap().parse().ok().unwrap() } }