#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000 * 1000;
int a[maxn], b[maxn], n, m;
vector<int> vec;
int main() {
  vec.reserve(1 << 20);
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) scanf("%d", a + i);
  for (int i = 0; i < m; i++) scanf("%d", b + i);
  for (int i = 30; i >= 0; i--)
    for (int j = 0; j < n; j++)
      if ((a[j] >> i) & 1) vec.push_back(i);
  sort(b, b + m);
  int p;
  for (p = 0; p < m; p++) {
    while (((int)(vec).size()) and vec.back() < b[p]) vec.pop_back();
    if (!((int)(vec).size())) break;
    int x = vec.back();
    vec.pop_back();
    for (int i = x - 1; i >= b[p]; i--) vec.push_back(i);
  }
  printf("%d", p);
  return 0;
}
