# Memory for Arrays

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 a i cells. You need to find memory for m arrays in your program. The j-th array takes 2 b j 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 a 1, a 2, …, a n (1 ≤ a i ≤ 109). The next line contains m integers b 1, b 2, …, b m (1 ≤ 2 b i ≤ 109).

Output

Print a single integer — the answer to the problem.

Examples

input

5 38 4 3 2 23 2 2

output

2

input

10 61 1 1 1 1 1 1 1 1 10 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.

Solution:

#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>

using namespace std;

int backup, b, c, a;

int main() {
int n, m;
scanf("%d %d", &n, &m);
for (int j=0;j<30;j++) c[j] = 0;
for (int i=0;i<n;i++) {
scanf("%d", a+i);
for (int j=0;j<30;j++)
if (a[i] & (1 << j)) c[j]++;
}
for (int j=0;j<30;j++) b[j] = 0;
for (int i=0;i<m;i++) {
int foo;
scanf("%d", &foo);
b[foo]++;
}
for (int j=0;j<30;j++) backup[j] = b[j];
int ll = 0, rr = m;
while (ll < rr) {
int mid = (ll+rr+1) >> 1;
for (int j=0;j<=30;j++) b[j] = 0;
int need = mid;
for (int j=0;j<30;j++)
if (backup[j] <= need) {
b[j] = backup[j];
need -= backup[j];
} else {
b[j] = need;
need = 0;
break;
}
for (int j=0;j<30;j++) {
int mn = c[j];
if (b[j] < mn) mn = b[j];
b[j] -= mn;
b[j+1] += (b[j]+1)/2;
}
if (b == 0) ll = mid;
else rr = mid-1;
}
printf("%d\n", ll);
return 0;
}