using System; using static System.Console; using System.Linq; using System.Collections.Generic; class Program { static int NN => int.Parse(ReadLine()); static int[] NList => ReadLine().Split().Select(int.Parse).ToArray(); public static void Main() { Solve(); } static void Solve() { var c = NList; var (n, h, x) = (c[0], c[1], c[2]); var g = NN; var glist = new int[0]; if (g > 0) glist = NList; else ReadLine(); var b = NN; var blist = new int[0]; if (b > 0) blist = NList; else ReadLine(); if (g + b == 0) { WriteLine(0); return; } var list = new List<(int pos, int val)>(); foreach (var gi in glist) list.Add((gi, 1)); foreach (var bi in blist) list.Add((bi, -1)); list.Sort((l, r) => l.pos.CompareTo(r.pos)); var cp = new List(); for (var i = 0; i < Math.Min(list[0].pos, x); ++i) cp.Add(0); cp.Add(list[0].val); for (var i = 1; i < list.Count; ++i) { for (var j = 0; j < Math.Min(list[i].pos - list[i - 1].pos - 1, x); ++j) cp.Add(0); cp.Add(list[i].val); } for (var i = 0; i < Math.Min(n - list.Last().pos, x); ++i) cp.Add(0); var dp = new int[cp.Count][]; var INF = int.MinValue / 2; for (var i = 0; i < dp.Length; ++i) dp[i] = Enumerable.Repeat(INF, Math.Min(h + 1, b + 1)).ToArray(); dp[0][0] = 0; for (var i = 0; i < dp.Length; ++i) for (var j = 0; j < dp[i].Length; ++j) { if (i + 1 < dp.Length) dp[i + 1][j] = Math.Max(dp[i + 1][j], dp[i][j] + cp[i + 1]); if (i + x < dp.Length && j + 1 < dp[i].Length) dp[i + x][j + 1] = Math.Max(dp[i + x][j + 1], dp[i][j] + cp[i + x]); } var ans = INF; for (var i = 0; i < dp[dp.Length - 1].Length; ++i) ans = Math.Max(ans, dp[dp.Length - 1][i]); WriteLine(ans); } }