#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];
int l,d,n,m;

ll sqr(ll x){
    return x*x;    
}

bool ok(int i,int i1,int j,int j1){
   ll temp = l - (x[j] - x[i] + y[j1] - y[i1]);
   if (temp < 0) return false;
   temp = temp * 1LL * temp;
   temp -= d*1LL*d + (y[i1] - x[i])*1LL*(y[i1] - x[i]);
   temp -= d*1LL*d + (y[j1] - x[j])*1LL*(y[j1] - x[j]);
   if (temp < 0) return false;
   temp = temp * 1LL * temp;
   temp -= 4LL * (d*1LL*d + (y[i1] - x[i])*1LL*(y[i1] - x[i])) * (d*1LL*d + (y[j1] - x[j])*1LL*(y[j1] - x[j]));
   return temp > 0;
}


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]);

  int ans = 0;

  for (int i = 0; i < n; i++)
      for (int j = 0; j < m; j++){
        int ptr1, ptr2;
        ptr1 = i;
        ptr2 = j; 
        if (!ok(i,j,i,j))
            continue;
        while (ptr2 < m-1 && ok(i,j,ptr1,ptr2+1)){
            ptr2++;
        }
        ans = max(ans, 2 + ptr2 - j);

        while (ptr1 < n-1){
            ptr1++;
            while (ptr2 >= j && !ok(i,j,ptr1,ptr2))
                ptr2--;
            if (ptr2 < j)
                break;
            ans = max(ans, 2 + ptr1 + ptr2 - i - j);
        }
      }

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