#include <bits/stdc++.h>
using namespace std;
const long long int INF = (long long int)1e9 + 10;
const long long int INFLL = (long long int)1e18 + 10;
const long double EPS = 1e-10;
const long long int MOD = 1e9 + 7;
template <class T>
T &chmin(T &a, const T &b) {
  return a = min(a, b);
}
template <class T>
T &chmax(T &a, const T &b) {
  return a = max(a, b);
}
template <class T>
inline T sq(T a) {
  return a * a;
}
const int MAX_N = 1000010;
int n, m;
int a[MAX_N], b[MAX_N], c[MAX_N];
int ans = 0;
int main() {
  scanf("%d %d", &n, &m);
  for (long long int i = (0); i < (long long int)(n); i++) {
    scanf("%d", &a[i]);
    for (long long int j = (0); j < (long long int)(31); j++)
      if (a[i] & (1LL << (j))) c[j]++;
  }
  for (long long int i = (0); i < (long long int)(m); i++) scanf("%d", &b[i]);
  sort(b, b + m);
  for (long long int i = (0); i < (long long int)(m); i++) {
    for (long long int j = (b[i]); j < (long long int)(31); j++)
      if (c[j]) {
        c[j]--;
        for (long long int k = (b[i]); k < (long long int)(j); k++) c[k]++;
        ans++;
        break;
      }
  }
  printf("%d\n", ans);
  return 0;
}
