#include <iostream>
#include <fstream>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cassert>
#include <ctime>
#include <algorithm>
#include <queue>
#include <memory.h>
#include <stack>
#define mp make_pair
#define pb push_back                     

#if ( _WIN32 || __WIN32__ )
    #define LLD "%I64d"
#else
    #define LLD "%lld"
#endif

using namespace std;

typedef long long ll;
typedef long double ld;

const int MAXN = 2100;

const ld eps = 1e-6;

int x[MAXN];
int y[MAXN];
double sq[MAXN][MAXN];
int l,d,n,m;


int main(){
  freopen("birch.in","r",stdin);
  freopen("birch.out","w",stdout);


  scanf("%d %d %d",&l,&d,&n);

  assert(0 <= n && n <= MAXN);

  for (int i = 0; i < n; i++)
    scanf("%d",&x[i]);

  scanf("%d",&m);
  assert(0 <= m && m <= MAXN);
  for (int j = 0; j < m; j++)
    scanf("%d",&y[j]);


  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++)
        sq[i][j] = sqrt((x[i] - y[j]) * 1LL * (x[i] - y[j]) + d * 1LL * d);

  int ans = 0;

  for (int i = 0; i < n; i++)
    for (int j = i; j < n; j++)
      for (int i1 = 0; i1 < m; i1++)
        for (int j1 = i1; j1 < m; j1++){
           long double len = x[j] - x[i] + y[j1] - y[i1];
           len += sq[i][i1];
           len += sq[j][j1];
           if (len <= l + eps)
               ans = max(ans, j-i+j1-i1+2);
        }

   cout << ans << endl;         
   return 0;
}