import std.stdio; import std.string; import std.conv; import std.algorithm; import std.range; import std.array; // つながりの長さを求める(xsから始める) -------------------- int loop(int[] xs, int[] ys, int before=int.max, int acc=0){ if(!xs.length) return acc; if(xs[$-1] < before) return loop(ys, xs[0..$-1], xs[$-1], acc+1); return xs.length >= 1 ? loop(xs[0..$-1], ys, before, acc): acc; } // main---------------- void main(){ //input readln; auto ws = readln.chomp.split(" ").map!(to!int).array.sort; readln; auto bs = readln.chomp.split(" ").map!(to!int).array.sort; //solve writeln( max(loop(ws, bs), loop(bs, ws)) ); }