#include <bits/stdc++.h>
using namespace std;
int b[1000005], a[40];
int main() {
  int n, m, d;
  cin >> n >> m;
  for (int(i) = (0); (i) < (n); (i)++) {
    scanf("%d", &d);
    int j = 0;
    while (d) a[j++] += d & 1, d /= 2;
  }
  for (int(i) = (0); (i) < (m); (i)++) scanf("%d", &b[i]);
  sort(b, b + m);
  for (int(i) = (0); (i) < (m); (i)++) {
    int j = b[i];
    while (j < 32 && !a[j]) a[j++] = 1;
    if (j == 32) {
      cout << i << endl;
      return 0;
    }
    a[j]--;
  }
  cout << m << endl;
  return 0;
}
