#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                     
#define setval(a,v) memset(a,v,sizeof(a))

#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 double eps = 1e-6;
const double inf = 1e100;

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

ld val[MAXN*2][MAXN];

double getmin(int sum,int l,int r){
    ld res = 1e100;
    for (int x = l; x < r; x++)
       res = min(res,val[sum][x]);      
    return res;
}

bool check(int cnt){
    for (int sum = 0; sum < n+m; sum++){
        int l,r;
        l = r = min(m,sum + cnt - 1);
        for (int i = 0; i < n && i <= sum; i++){
            int j = sum - i;
            if (j >= m)
                continue;
            while (l > j && i + cnt - l + j <= n)
                l--;
            while (r > l && (i + cnt - r + j > n || r >= j+cnt))
                r--;
            double temp = getmin(sum+cnt-2,l,r);
            temp -= x[i];
            temp -= y[j];
            temp += sqrt((x[i] - y[j]) * 1LL * (x[i] - y[j]) + d * 1LL * d);
            if (temp <= ::l + eps)
                return true;
        }
    }
    return false;
}


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++)
        val[i][j] = inf;

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

  int l = 2;
  int r = n+m+1;
  if (!check(2)){
    printf("0\n");
    return 0;
  }

  while (r - l > 1){
      int mid = (l+r)/2;
      if (!check(mid))
        r = mid;
      else
        l = mid;
  }

  printf("%d\n",l);      
  return 0;
}