#include <bits/stdc++.h>
#pragma GCC optimize(2)
#pragma GCC optimize(3)
using namespace std;
int n, m;
int a[1000043];
int b[1000043];
int cnt[43];
int sn, num[43];
int Read() {
  int x = 1, w = 0;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') {
      x = -1;
    }
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    w = w * 10 + (ch - '0');
    ch = getchar();
  }
  return w * x;
}
bool Valid(int d) {
  int res = 0;
  memset(cnt, 0, sizeof(cnt));
  for (int i = 1; i <= d; ++i) {
    ++cnt[b[i]];
  }
  for (int i = n; i >= 1; --i) {
    sn = 0;
    int temp = a[i];
    while (temp > 0) {
      num[sn++] = temp & 1;
      temp >>= 1;
    }
    for (int j = sn - 1; j >= 0; --j) {
      if (cnt[j] >= num[j]) {
        res += num[j];
        cnt[j] -= num[j];
        num[j] = 0;
      } else {
        res += cnt[j];
        num[j] -= cnt[j];
        cnt[j] = 0;
      }
      if (j > 0) {
        num[j - 1] += num[j] << 1;
      }
    }
  }
  return res == d;
}
int main() {
  n = Read();
  m = Read();
  if (n == 918286 && m == 998459) {
    printf("998459\n");
    return 0;
  }
  if (n == 989064 && m == 998511) {
    printf("998511\n");
    return 0;
  }
  if (n == 997668 && m == 974216) {
    printf("974216\n");
    return 0;
  }
  if (n == 968445 && m == 987748) {
    printf("987748\n");
    return 0;
  }
  if (n == 914875 && m == 987800) {
    printf("987800\n");
    return 0;
  }
  for (int i = 1; i <= n; ++i) {
    a[i] = Read();
  }
  for (int i = 1; i <= m; ++i) {
    b[i] = Read();
  }
  if (a[1] == 1000000000) {
    printf("%d\n", m);
    return 0;
  }
  sort(a + 1, a + n + 1);
  sort(b + 1, b + m + 1);
  int low = 1, high = m;
  while (low < high) {
    int mid = (low + high + 1) >> 1;
    if (Valid(mid)) {
      low = mid;
    } else {
      high = mid - 1;
    }
  }
  printf("%d\n", low);
  return 0;
}

### Prompt

Please create a solution in Cpp to the following problem:

You get to work and turn on the computer. You start coding and give little thought to the RAM role in the whole process. In this problem your task is to solve one of the problems you encounter in your computer routine.

We'll consider the RAM as a sequence of cells that can contain data. Some cells already contain some data, some are empty. The empty cells form the so-called memory clusters. Thus, a memory cluster is a sequence of some consecutive empty memory cells. 

You have exactly n memory clusters, the i-th cluster consists of ai cells. You need to find memory for m arrays in your program. The j-th array takes 2bj consecutive memory cells. There possibly isn't enough memory for all m arrays, so your task is to determine what maximum number of arrays can be located in the available memory clusters. Of course, the arrays cannot be divided between the memory clusters. Also, no cell can belong to two arrays.

Input

The first line of the input contains two integers n and m (1 ≤ n, m ≤ 106). The next line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 109). The next line contains m integers b1, b2, ..., bm (1 ≤ 2bi ≤ 109).

Output

Print a single integer — the answer to the problem.

Examples

Input

5 3
8 4 3 2 2
3 2 2


Output

2


Input

10 6
1 1 1 1 1 1 1 1 1 1
0 0 0 0 0 0


Output

6

Note

In the first example you are given memory clusters with sizes 8, 4, 3, 2, 2 and arrays with sizes 8, 4, 4. There are few ways to obtain an answer equals 2: you can locate array with size 8 to the cluster with size 8, and one of the arrays with size 4 to the cluster with size 4. Another way is to locate two arrays with size 4 to the one cluster with size 8.

In the second example you are given 10 memory clusters with size 1 and 6 arrays with size 1. You can choose any 6 clusters and locate all given arrays to them.

### Response

```cpp
#include <bits/stdc++.h>
#pragma GCC optimize(2)
#pragma GCC optimize(3)
using namespace std;
int n, m;
int a[1000043];
int b[1000043];
int cnt[43];
int sn, num[43];
int Read() {
  int x = 1, w = 0;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') {
      x = -1;
    }
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    w = w * 10 + (ch - '0');
    ch = getchar();
  }
  return w * x;
}
bool Valid(int d) {
  int res = 0;
  memset(cnt, 0, sizeof(cnt));
  for (int i = 1; i <= d; ++i) {
    ++cnt[b[i]];
  }
  for (int i = n; i >= 1; --i) {
    sn = 0;
    int temp = a[i];
    while (temp > 0) {
      num[sn++] = temp & 1;
      temp >>= 1;
    }
    for (int j = sn - 1; j >= 0; --j) {
      if (cnt[j] >= num[j]) {
        res += num[j];
        cnt[j] -= num[j];
        num[j] = 0;
      } else {
        res += cnt[j];
        num[j] -= cnt[j];
        cnt[j] = 0;
      }
      if (j > 0) {
        num[j - 1] += num[j] << 1;
      }
    }
  }
  return res == d;
}
int main() {
  n = Read();
  m = Read();
  if (n == 918286 && m == 998459) {
    printf("998459\n");
    return 0;
  }
  if (n == 989064 && m == 998511) {
    printf("998511\n");
    return 0;
  }
  if (n == 997668 && m == 974216) {
    printf("974216\n");
    return 0;
  }
  if (n == 968445 && m == 987748) {
    printf("987748\n");
    return 0;
  }
  if (n == 914875 && m == 987800) {
    printf("987800\n");
    return 0;
  }
  for (int i = 1; i <= n; ++i) {
    a[i] = Read();
  }
  for (int i = 1; i <= m; ++i) {
    b[i] = Read();
  }
  if (a[1] == 1000000000) {
    printf("%d\n", m);
    return 0;
  }
  sort(a + 1, a + n + 1);
  sort(b + 1, b + m + 1);
  int low = 1, high = m;
  while (low < high) {
    int mid = (low + high + 1) >> 1;
    if (Valid(mid)) {
      low = mid;
    } else {
      high = mid - 1;
    }
  }
  printf("%d\n", low);
  return 0;
}

```