fn main() { let stdin = std::io::read_to_string(std::io::stdin().lock()).unwrap(); let mut stdin = stdin.split_ascii_whitespace(); let n_w: usize = stdin.next().unwrap().parse().unwrap(); let w: Vec = (0..n_w) .map(|_| stdin.next().unwrap().parse().unwrap()) .collect(); let n_b: usize = stdin.next().unwrap().parse().unwrap(); let b: Vec = (0..n_b) .map(|_| stdin.next().unwrap().parse().unwrap()) .collect(); use std::io::Write; std::io::stdout() .lock() .write_all(output(solve(w, b)).as_bytes()) .unwrap(); } fn solve(mut w: Vec, mut b: Vec) -> u8 { w.sort_unstable(); b.sort_unstable(); let blocks = [w, b]; (0..=1) .map(|first| { let mut count = 0; let mut prev = 0; let mut i = 0; let mut j = 0; loop { while let Some(&len) = blocks[first].get(i) { if len > prev { break; } i += 1; } match blocks[first].get(i) { Some(&len) => { count += 1; prev = len; i += 1; } None => return count, } while let Some(&len) = blocks[first ^ 1].get(j) { if len > prev { break; } j += 1; } match blocks[first ^ 1].get(j) { Some(&len) => { count += 1; prev = len; j += 1; } None => return count, } } }) .max() .unwrap() } fn output(ans: u8) -> String { ans.to_string() + "\n" }