#include using namespace std; //* ATCODER #include using namespace atcoder; typedef modint998244353 mint; //*/ /* BOOST MULTIPRECISION #include using namespace boost::multiprecision; //*/ typedef long long ll; #define rep(i, s, n) for (int i = (int)(s); i < (int)(n); i++) #define rrep(i, s, n) for (int i = (int)(n)-1; i >= (int)(s); i--) template bool chmin(T &a, const T &b) { if (a <= b) return false; a = b; return true; } template bool chmax(T &a, const T &b) { if (a >= b) return false; a = b; return true; } template T max(vector &a){ assert(!a.empty()); T ret = a[0]; for (int i=0; i<(int)a.size(); i++) chmax(ret, a[i]); return ret; } template T min(vector &a){ assert(!a.empty()); T ret = a[0]; for (int i=0; i<(int)a.size(); i++) chmin(ret, a[i]); return ret; } template T sum(vector &a){ T ret = 0; for (int i=0; i<(int)a.size(); i++) ret += a[i]; return ret; } int main(){ int n, h, x; cin >> n >> h >> x; int G; cin >> G; vector g(G); rep(i,0,G) cin >> g[i]; int B; cin >> B; vector b(B); rep(i,0,B) cin >> b[i]; vector score(n); rep(i,0,G) score[g[i]-1] = 1; rep(i,0,B) score[b[i]-1] = - 1; vector> dp(n+1, vector(201, 1e9)); dp[0][100] = 0; rep(i,0,n){ rep(j,0,201){ if (0 <= j+score[i] && j+score[i] <= 200){ if (i+1-x >= 0){ chmin(dp[i+1][j+score[i]], dp[i+1-x][j] + 1); } chmin(dp[i+1][j+score[i]], dp[i][j]); } } } int ans = -113; rep(i,0,201){ if (dp[n][i] <= h){ chmax(ans, i - 100); } } cout << ans << '\n'; }