use std::io; fn main() { let mut buf = String::new(); io::stdin().read_line(&mut buf) .expect("Failed to read line"); let _n: i32 = buf.trim().parse() .expect("not integer"); let mut buf = String::new(); io::stdin().read_line(&mut buf) .expect("Failed to read line"); let a = buf.trim().split_whitespace() .map(|x| x.parse::().unwrap()); let mut buf = String::new(); io::stdin().read_line(&mut buf) .expect("Failed to read line"); let b = buf.trim().split_whitespace() .map(|x| x.parse::().unwrap()); let mut buf = String::new(); io::stdin().read_line(&mut buf) .expect("Failed to read line"); let c = buf.trim().split_whitespace() .map(|x| x.parse::().unwrap()); let an = a.filter(|x| *x % 3 != 0).count(); let bn = b.filter(|x| *x % 3 != 0).count(); let cn = c.filter(|x| *x % 3 != 0).count(); println!("{}", an * bn * cn); }