use std::io::*; fn solve(w: &Vec, b: &Vec) -> usize { let mut ans = 0; let mut now = 1 << 30; let mut widx = 0; let mut bidx = 0; loop { // white while widx < w.len() && w[widx] >= now { widx += 1; } if widx == w.len() { break; } now = w[widx]; widx += 1; ans += 1; // black while bidx < b.len() && b[bidx] >= now { bidx += 1; } if bidx == b.len() { break; } now = b[bidx]; bidx += 1; ans += 1; } ans } fn main() { let mut s: String = String::new(); std::io::stdin().read_to_string(&mut s).ok(); let mut itr = s.trim().split_whitespace(); let n: usize = itr.next().unwrap().parse().unwrap(); let mut w: Vec = (0..n) .map(|_| itr.next().unwrap().parse().unwrap()) .collect(); let m: usize = itr.next().unwrap().parse().unwrap(); let mut b: Vec = (0..m) .map(|_| itr.next().unwrap().parse().unwrap()) .collect(); w.sort_by(|a, b| b.cmp(a)); b.sort_by(|a, b| b.cmp(a)); w.dedup(); b.dedup(); println!("{}", std::cmp::max(solve(&w, &b), solve(&b, &w))); }