use std::io::Read; fn main() { let mut s = String::new(); std::io::stdin().read_to_string(&mut s).ok(); let v: Vec = s.split_whitespace().flat_map(str::parse).collect(); let mut a = [0u64; 3]; for i in 0..3 * v[0] { if v[i + 1] % 3 > 0 { a[i / v[0]] += 1 } } println!("{}", a[0] * a[1] * a[2]) }