#include <bits/stdc++.h>
using namespace std;
int N, M;
vector<int> p, t;
vector<int> gl, gr;
vector<int> dp;
int take_left(int i, int how) {
  i -= (how - 1);
  if (i < 0) return -1;
  return gl[i];
}
int take_right(int i, int how) {
  i += (how - 1);
  if (i >= N) return N;
  return gr[i];
}
int _cnt[200010];
int cnt(int lo, int hi) {
  if (lo) return _cnt[hi] - _cnt[lo - 1];
  return _cnt[hi];
}
int main() {
  scanf("%d%d", &N, &M);
  p.resize(N), t.resize(M);
  gl.resize(N), gr.resize(N);
  dp.resize(N, 0);
  for (int i = 0; i < N; ++i) scanf("%d", &p[i]);
  for (int i = 0; i < M; ++i) scanf("%d", &t[i]), ++_cnt[t[i]];
  sort(p.begin(), p.end()), sort(t.begin(), t.end());
  for (int i = 1; i < 200010; ++i) _cnt[i] += _cnt[i - 1];
  gl[0] = 0, gr[N - 1] = N - 1;
  for (int i = 1; i < N; ++i) gl[i] = (p[i - 1] + 1 == p[i]) ? gl[i - 1] : i;
  for (int i = N - 2; i >= 0; --i)
    gr[i] = (p[i] + 1 == p[i + 1]) ? gr[i + 1] : i;
  for (int i = 0; i < N; ++i) {
    if (i) (dp[i]) = max((dp[i]), (dp[i - 1]));
    int base = i ? dp[i - 1] : 0;
    for (int j = 0; j < M; ++j)
      if (t[j] <= p[i]) {
        int lp = take_left(i, p[i] - t[j] + 1);
        if (lp >= 0)
          (base) = max((base), (cnt(t[j], p[i]) + (lp ? dp[lp - 1] : 0)));
      } else {
        int rp = take_right(i + 1, t[j] - p[i]);
        if (rp < N) (dp[rp]) = max((dp[rp]), (cnt(p[i] + 1, t[j]) + base));
      }
    (dp[i]) = max((dp[i]), (base));
  }
  printf("%d\n", *max_element(dp.begin(), dp.end()));
  return 0;
}
