def sol w,b,f tmp = 100 ans = 0 loop{ if ans % 2 == f i = w.find_index{|x|x < tmp} if i tmp = w[i] ans += 1 w = w[(i + 1)..-1].to_a else break end else i = b.find_index{|x|x < tmp} if i tmp = b[i] ans += 1 b = b[(i + 1)..-1].to_a else break end end } return ans end n_w = gets.to_i w = gets.split.map(&:to_i).sort.reverse n_b = gets.to_i b = gets.split.map(&:to_i).sort.reverse p [sol(w,b,0),sol(w,b,1)].max