n, h, x = map(int,input().split()) G = int(input()) g = set(map(int,input().split())) B = int(input()) b = set(map(int,input().split())) newb = set() for a in b: for i in range(a-x, a+x+1): if 0 <= i <= n: newb.add(i) ans_base = 0 for a in g: if a not in newb: ans_base += 1 m = len(newb) score = [0] * m newb_list = sorted(list(newb)) for i, a in enumerate(newb_list): if a in b: score[i] -= 1 if a in g: score[i] += 1 r = min(B, h) dp = [[- 10 ** 9 for i in range(r+1)] for j in range(m)] dp[0][0] = 0 for i in range(1, m): for j in range(r+1): dp[i][j] = max(dp[i][j], dp[i-1][j] + score[i]) if j >= 1 and i-x >= 0: dp[i][j] = max(dp[i][j], dp[i-x][j-1] + score[i]) ans = max(dp[m-1]) print(ans + ans_base)