#include <bits/stdc++.h>
using namespace std;
struct ww {
  int l, r, s;
} b[200010];
int i, j, k, n, m, K;
int f[200010][2], a[200010], g[200010], h[200010], si[200010], pr[200010],
    hou[200010];
inline void dp() {
  int i, j, k, last;
  memset(g, 120, sizeof(g));
  g[0] = 0;
  for (i = 1; i <= m; i++) hou[i] = n + 1;
  for (i = 1; i <= n; i++) {
    pr[i + 1] = max(pr[i + 1], pr[i]);
    f[i][1] = pr[i];
    for (j = 0; j <= m; j++)
      if (g[j] < 1e9) {
        int A = g[j];
        int l = b[i].r - (si[i] - si[A]);
        int re = j + h[b[i].r] - h[l];
        if (re > f[i][0]) f[i][0] = re;
      }
    last = 0;
    for (j = 1; j <= m; j++)
      if (a[j] > b[i].r) {
        for (; hou[j];) {
          int A = hou[j] - 1;
          if (b[i].r + (si[A] - si[i]) < a[j]) break;
          hou[j]--;
        }
        int re = f[i][0] + j - last;
        if (re > pr[hou[j]]) pr[hou[j]] = re;
      } else
        last = j;
    g[f[i][0]] = min(g[f[i][0]], i);
    g[f[i][1]] = min(g[f[i][1]], i);
  }
  printf("%d\n", max(f[n][0], f[n][1]));
}
int main() {
  scanf("%d%d", &K, &m);
  for (i = 1; i <= K; i++) scanf("%d", &a[i]);
  sort(a + 1, a + K + 1);
  for (i = 1; i <= K; i++)
    if (i == 1 || a[i] > b[n].r + 1) {
      b[++n].s = 1;
      b[n].l = b[n].r = a[i];
    } else
      b[n].s++, b[n].r++;
  for (i = 1; i <= m; i++) scanf("%d", &a[i]), h[a[i]]++;
  for (i = 1; i <= 200010 - 1; i++) h[i] += h[i - 1];
  sort(a + 1, a + m + 1);
  for (i = 1; i <= n; i++) si[i] = si[i - 1] + b[i].s;
  dp();
  return 0;
}
