#include <bits/stdc++.h>
using namespace std;
long long exp(long long taban, long long us) {
  long long carpan = taban % 1000000007;
  long long temp = us;
  long long res = 1;
  while (temp) {
    if (temp % 2) res = (res * carpan) % 1000000007;
    temp /= 2;
    carpan = (carpan * carpan) % 1000000007;
  }
  return res;
}
long long ebob(long long a, long long b) {
  if (!a) return b;
  return ebob(b % a, a);
}
long long ekok(long long a, long long b) { return (a * b) / ebob(a, b); }
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, m;
  cin >> n >> m;
  vector<vector<int>> cnt(64);
  for (int i = 0; i < n; i++) {
    int sayi;
    cin >> sayi;
    int u = 0;
    while (sayi) {
      if (sayi % 2) cnt[u].push_back(i);
      sayi /= 2;
      u++;
    }
  }
  vector<int> vec(m);
  for (int i = 0; i < m; i++) {
    cin >> vec[i];
  }
  sort(vec.begin(), vec.end());
  int u = 0;
  int ans = 0;
  for (int i = 0; i < m; i++) {
    u = 0;
    while (u < vec[i]) u++;
    while (u < 64 && cnt[u].empty()) u++;
    if (u == 64) break;
    int tmp = cnt[u].back();
    cnt[u].pop_back();
    for (int j = vec[i]; j < u; j++) cnt[j].push_back(tmp);
    ans++;
  }
  cout << ans << endl;
}
