#include <cstdio>
#include <cassert>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cmath>
#include <iostream>

using namespace std;

#define mp make_pair
#define pb push_back
#define sz(x) ((int)(x).size())
#define eprintf(...) fprintf(stderr, __VA_ARGS__)

typedef vector<int> vi;

class segm_tree {
  vector<double> tr;
  int off;

  public:
  segm_tree(int n = 0) {
    off = 1; while (off < n) off <<= 1;
    tr = vector<double>(2 * off, 1e100);
  }
  void relaxPostpone(int x, double val) {
    assert(0 <= x && x < off);
    tr[x + off] = min(tr[x + off], val);
  }
  void update() {
    for (int i = off - 1; i >= 1; i--)
      tr[i] = min(tr[2 * i], tr[2 * i + 1]);
  }
  double get(int l, int r) {
    if (l <= r) {
      assert(0 <= l && r < off);
    }
    l += off; r += off;
    double res = 1e100;
    while (l <= r) {
      if (l & 1) res = min(res, tr[l++]);
      if (!(r & 1)) res = min(res, tr[r--]);
      l >>= 1; r >>= 1;
    }
    return res;
  }
};

const double EPS = 1e-9;
double maxlen, line_dist;
int n, m;
vi xs, ys;

double dist(int a, int b) {
  return sqrt(line_dist * line_dist + double(a - b) * (a - b));
}

vector<segm_tree> trs;
vi mina, maxa;

bool check(int mincnt) {
  for (int a = 0; a < n; a++)
  for (int b = 0; b < m; b++) {
    if (n + m - a - b < mincnt) break;

    int sum = mincnt + a + b - 2;
    if (sum < 0 || sum >= sz(trs)) continue;

    int l = a, r = sum - b;
    l = max(l, mina[sum]);
    r = min(r, maxa[sum]);
    if (l > r) continue;

    double res = trs[sum].get(l - mina[sum], r - mina[sum]);
    res += dist(xs[a], ys[b]);
    res -= xs[a] + ys[b];
    if (res <= maxlen + EPS) {
      return true;
    }
  }
  return false;
}

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

  while (scanf("%lf%lf%d", &maxlen, &line_dist, &n) >= 1) {
    xs = vi(n);
    for (int i = 0; i < n; i++)
      scanf("%d", &xs[i]);
    sort(xs.begin(), xs.end());

    scanf("%d", &m);
    ys = vi(m);
    for (int i = 0; i < m; i++)
      scanf("%d", &ys[i]);
    sort(ys.begin(), ys.end());

    trs = vector<segm_tree>(n + m);
    {
      mina = vi(sz(trs), 1e9);
      maxa = vi(sz(trs), -1);
      for (int a = 0; a < n; a++)
      for (int b = 0; b < m; b++) {
        mina[a + b] = min(mina[a + b], a);
        maxa[a + b] = max(maxa[a + b], a);
      }
      for (int i = 0; i < sz(trs); i++) {
        trs[i] = segm_tree(maxa[i] - mina[i] + 1);
      }
    }
    for (int a = 0; a < n; a++) {
      for (int b = 0; b < m; b++) {
        double csum = xs[a] + ys[b] + dist(xs[a], ys[b]);
        trs[a + b].relaxPostpone(a - mina[a + b], csum);
      }
    }
    for (int i = 0; i < sz(trs); i++)
      trs[i].update();

    int L = 2, R = n + m + 1;
    assert(!check(R));
    if (!check(L)) {
      L = R = 0;
    }

    while (L + 1 < R) {
      int M = (L + R) / 2;
      if (check(M)) L = M;
      else R = M;
    }
    printf("%d\n", L);
  }
  return 0;
}
