using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace foryuki { class Program { static void Main(string[] args) { int Nw = int.Parse(Console.ReadLine()); int[] W = ConvertStringArrayToIntArray(Console.ReadLine().Split()); int Nb = int.Parse(Console.ReadLine()); int[] B = ConvertStringArrayToIntArray(Console.ReadLine().Split()); int cnt1 = 0; int Wm = 0; int Bm = 0; while (true) { var q = from x in W where x > Bm orderby x select x; if (q.Count() != 0) { Wm = q.Min(); cnt1++; } else { break; } var p = from x in B where x > Wm orderby x select x; if (p.Count() != 0) { Bm = p.Min(); cnt1++; } else { break; } } //--------------------------- int cnt2 = 0; Wm = 0; Bm = 0; while (true) { var p = from x in B where x > Wm orderby x select x; if (p.Count() != 0) { Bm = p.Min(); cnt2++; } else { break; } var q = from x in W where x > Bm orderby x select x; if (q.Count() != 0) { Wm = q.Min(); cnt2++; } else { break; } } Console.WriteLine(Math.Max( cnt1,cnt2)); } //------------------------------------------------------------- static int[] ConvertStringArrayToIntArray(string[] str) { int[] b = Array.ConvertAll(str, delegate(string value) { return int.Parse(value); }); return b; } static List ConvertStringArrayToIntList(string[] str) { var list = new List(); foreach (var c in str) { list.Add(int.Parse(c)); } return list; } } }