#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;

struct minStack{
    pair<double,double> a[MAXN];
    int ptr;
    void push(double x){
        a[ptr] = mp(x,min(x,a[ptr-1].second));
        ptr++;
    }
    double pop(){
        ptr--;
        return a[ptr].first;
    }
    double get(){
        return a[ptr-1].second;
    }
    bool empty(){
       return ptr == 1;
    }
    void clear(){
       ptr = 1;
    }
    minStack(){
       a[0] = mp(inf,inf);
       ptr = 1;
    }
};

struct minQueue{           
    minStack a,b;
    void push(double x){
        a.push(x);
    }
    void pop(){
        if (b.empty()){
            while (!a.empty()){
                b.push(a.pop());
            }
        }
        assert(!b.empty());
        b.pop();
    }
    double get(){
        return min(a.get(),b.get());
    }
    void clear(){
        a.clear();
        b.clear();
    }
};

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

double sq[MAXN][MAXN];

//ld val[MAXN*2][MAXN];

double val(int sum,int j){
    int i = sum - j;
    assert(0 <= i && i < n);
    return x[i] + y[j] + sq[i][j];
}

bool check(int cnt){
    minQueue q;
    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--;
                q.push(val(sum+cnt-2,l));
            }                                     
            while (r > l && (i + cnt - r + j > n || r >= j+cnt)){
                r--;
                q.pop();
            }
            double temp = q.get();
            temp -= x[i];
            temp -= y[j];
            temp += sq[i][j];   
            if (temp <= ::l + eps){
                return true;
            }
        }
        q.clear();
    }
    return false;
}


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

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

  return l;     
}

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 = solve();
  l = l+1e-4;
  assert(ans == solve());
  cout << ans << endl;
  return 0;
}