#include <bits/stdc++.h>
using namespace std;
int input() {
  bool minus = false;
  int result = 0;
  char ch;
  ch = getchar();
  while (true) {
    if (ch == '-') break;
    if (ch >= '0' && ch <= '9') break;
    ch = getchar();
  }
  if (ch == '-')
    minus = true;
  else
    result = ch - '0';
  while (true) {
    ch = getchar();
    if (ch < '0' || ch > '9') break;
    result = result * 10 + (ch - '0');
  }
  if (minus)
    return -result;
  else
    return result;
}
int ar[100];
vector<int> v;
int main() {
  int n, m, count1 = 0;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    int a;
    a = input();
    for (int j = 0; j <= log2(a); j++)
      if ((a >> j) % 2) ar[j]++;
  }
  for (int i = 0; i < m; i++) {
    int b;
    b = input();
    v.push_back(b);
  }
  sort(v.begin(), v.end());
  for (int i = 0; i < v.size(); i++) {
    int j;
    for (j = v[i]; j < 32 && !ar[j]; j++) ar[j]++;
    if (j == 32) break;
    ar[j]--;
    count1++;
  }
  cout << count1;
}
