import std.algorithm, std.array, std.container, std.range; import std.string, std.conv; import std.math, std.bigint, std.bitmanip, std.random; import std.stdio, std.typecons; void main() { auto nw = readln.chomp.to!int; auto wi = readln.split.map!(to!int).array; auto nb = readln.chomp.to!int; auto bi = readln.split.map!(to!int).array; wi.sort!("a > b"); bi.sort!("a > b"); writeln(max(calc(wi, bi, 0, 0), calc(bi, wi, 0, 0))); } int calc(int[] ai, int[] bi, int prev, int acc) { if (ai.empty) { return acc; } else if (prev == 0) { return calc(bi, ai[1..$], ai.front, acc + 1); } else { auto ci = ai.find!(x => x < prev); if (ci.empty) return acc; else return calc(bi, ci[1..$], ci.front, acc + 1); } }