#include <bits/stdc++.h>
using namespace std;
template <class T>
inline T LOW_BIT(T n);
template <class T>
inline int COUNT_BIT(T n);
template <class T>
inline T GCD(T a, T b);
template <class T>
inline T LCM(T a, T b);
bool isUpperCase(char c);
bool isLowerCase(char c);
bool isLetter(char c);
bool isDigit(char c);
char toLowerCase(char c);
char toUpperCase(char c);
template <class T>
string toString(T n);
template <class T>
void stoa(const string &s, int &n, T A[]);
template <class T>
void atos(int n, T A[], string &s);
template <class T>
void atov(int n, T A[], vector<T> &vi);
template <class T>
void vtoa(const vector<T> &vi, int &n, T A[]);
template <class T>
void stov(const string &s, vector<T> &vi);
template <class T>
void vtos(const vector<T> &vi, string &s);
template <class T>
inline vector<pair<T, int> > factorize(T n);
int64_t modInverse2(int64_t a, int64_t m);
template <class T>
inline bool check_min(T &mn, const T &val);
template <class T>
inline bool check_max(T &mx, const T &val);
string testCaseOutTemp = "Case #%d: ";
int numThread = 4;
void initProgram() {}
class Task {
 public:
  ostringstream out;
  int testcase;
  int a1[32];
  int b1[32];
  int64_t a[32];
  int64_t b[32];
  int res;
  int n, m;
  void readInput() {
    res = 0;
    scanf("%d %d", &n, &m);
    int val;
    memset(a1, 0, sizeof a1);
    memset(b1, 0, sizeof b1);
    memset(b, 0, sizeof b);
    for (int i = 0, __e__ = (int)(n); i < __e__; ++i) {
      scanf("%d", &val);
      for (int j = 0, __e__ = (int)(32); j < __e__; ++j)
        if (((val) & (1 << (j)))) {
          a1[j]++;
        }
    }
    for (int i = 0, __e__ = (int)(m); i < __e__; ++i) {
      scanf("%d", &val);
      b1[val]++;
    }
  }
  bool ok(int m) {
    int sum = 0;
    for (int i = 0, __e__ = (int)(32); i < __e__; ++i) {
      if (sum + b1[i] <= m) {
        sum += b1[i];
        b[i] = b1[i];
      } else {
        b[i] = (m - sum);
        sum = m;
      }
    }
    int res = 0;
    for (int i = 0, __e__ = (int)(32); i < __e__; ++i) a[i] = a1[i];
    for (int i = (31), __e__ = (0); i >= __e__; --i) {
      for (int j = (31), __e__ = (i + 1); j >= __e__; --j)
        if (a[j]) {
          a[i] += a[j] * (j - i + 1);
          a[j] = 0;
        }
      int temp = min(a[i], b[i]);
      a[i] -= temp;
      b[i] -= temp;
      res += temp;
    }
    return res == m;
  }
  void process() {
    int lo = 0;
    int hi = m;
    while (lo <= hi) {
      int mid = (lo + hi) / 2;
      if (ok(mid)) {
        res = mid;
        lo = mid + 1;
      } else {
        hi = mid - 1;
      }
    }
    out << res << endl;
  }
};
int main() {
  srand(time(0));
  initProgram();
  int ntest = 1;
  {} {
    for (int i = 0, __e__ = (int)(ntest); i < __e__; ++i) {
      cerr << "processing test: " << i + 1 << endl;
      Task *pT = new Task();
      pT->testcase = i + 1;
      pT->readInput();
      pT->process();
      cout << pT->out.str();
      delete pT;
    }
  }
}
template <class T>
inline T LOW_BIT(T n) {
  return (n ^ (n - 1)) & n;
}
template <class T>
inline int COUNT_BIT(T n) {
  return (n == 0) ? 0 : (1 + COUNT_BIT(n & (n - 1)));
}
template <class T>
inline T GCD(T a, T b) {
  if (a < 0) return GCD(-a, b);
  if (b < 0) return GCD(a, -b);
  return (b == 0) ? a : GCD(b, a % b);
}
template <class T>
inline T LCM(T a, T b) {
  if (a < 0) return LCM(-a, b);
  if (b < 0) return LCM(a, -b);
  return a * (b / GCD(a, b));
}
bool isUpperCase(char c) { return c >= 'A' && c <= 'Z'; }
bool isLowerCase(char c) { return c >= 'a' && c <= 'z'; }
bool isLetter(char c) {
  return (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z');
}
bool isDigit(char c) { return c >= '0' && c <= '9'; }
char toLowerCase(char c) { return (isUpperCase(c)) ? (c + 32) : c; }
char toUpperCase(char c) { return (isLowerCase(c)) ? (c - 32) : c; }
template <class T>
string toString(T n) {
  ostringstream ost;
  ost << n;
  ost.flush();
  return ost.str();
}
template <class T>
inline vector<pair<T, int> > factorize(T n) {
  vector<pair<T, int> > R;
  for (T i = 2; n > 1;) {
    if (n % i == 0) {
      int C = 0;
      for (; n % i == 0; C++, n /= i)
        ;
      R.push_back(make_pair(i, C));
    }
    i++;
    if (i > n / i) i = n;
  }
  if (n > 1) R.push_back(make_pair(n, 1));
  return R;
}
template <class T>
void stoa(const string &s, int &n, T A[]) {
  n = 0;
  istringstream sin(s);
  for (T v; sin >> v; A[n++] = v)
    ;
}
template <class T>
void atos(int n, T A[], string &s) {
  ostringstream sout;
  for (int i = 0; i < n; i++) {
    if (i > 0) sout << ' ';
    sout << A[i];
  }
  s = sout.str();
}
template <class T>
void atov(int n, T A[], vector<T> &vi) {
  vi.clear();
  for (int i = 0; i < n; i++) vi.push_back(A[i]);
}
template <class T>
void vtoa(const vector<T> &vi, int &n, T A[]) {
  n = vi.size();
  for (int i = 0; i < n; i++) A[i] = vi[i];
}
template <class T>
void stov(const string &s, vector<T> &vi) {
  vi.clear();
  istringstream sin(s);
  for (T v; sin >> v; vi.push_bakc(v))
    ;
}
template <class T>
void vtos(const vector<T> &vi, string &s) {
  ostringstream sout;
  for (int i = 0; i < vi.size(); i++) {
    if (i > 0) sout << ' ';
    sout << vi[i];
  }
  s = sout.str();
}
int64_t fecma_pow(int64_t a, int64_t b, int64_t MOD) {
  int64_t x = 1, y = a;
  while (b != 0) {
    if (b % 2 == 1) {
      x = (x * y);
      x %= MOD;
    }
    y = (y * y);
    y %= MOD;
    b /= 2;
  }
  return x;
}
int64_t modInverse2(int64_t a, int64_t m) {
  int64_t B = fecma_pow(a, m - 2, m);
  if (B < 0) {
    B += (abs(B) / m + 1) * m;
    B %= m;
  }
  return B;
}
template <class T>
bool check_min(T &mn, const T &val) {
  if (val < mn) {
    mn = val;
    return true;
  }
  return false;
}
template <class T>
bool check_max(T &mx, const T &val) {
  if (mx < val) {
    mx = val;
    return true;
  }
  return false;
}

### Prompt

Please formulate a CPP solution 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>
using namespace std;
template <class T>
inline T LOW_BIT(T n);
template <class T>
inline int COUNT_BIT(T n);
template <class T>
inline T GCD(T a, T b);
template <class T>
inline T LCM(T a, T b);
bool isUpperCase(char c);
bool isLowerCase(char c);
bool isLetter(char c);
bool isDigit(char c);
char toLowerCase(char c);
char toUpperCase(char c);
template <class T>
string toString(T n);
template <class T>
void stoa(const string &s, int &n, T A[]);
template <class T>
void atos(int n, T A[], string &s);
template <class T>
void atov(int n, T A[], vector<T> &vi);
template <class T>
void vtoa(const vector<T> &vi, int &n, T A[]);
template <class T>
void stov(const string &s, vector<T> &vi);
template <class T>
void vtos(const vector<T> &vi, string &s);
template <class T>
inline vector<pair<T, int> > factorize(T n);
int64_t modInverse2(int64_t a, int64_t m);
template <class T>
inline bool check_min(T &mn, const T &val);
template <class T>
inline bool check_max(T &mx, const T &val);
string testCaseOutTemp = "Case #%d: ";
int numThread = 4;
void initProgram() {}
class Task {
 public:
  ostringstream out;
  int testcase;
  int a1[32];
  int b1[32];
  int64_t a[32];
  int64_t b[32];
  int res;
  int n, m;
  void readInput() {
    res = 0;
    scanf("%d %d", &n, &m);
    int val;
    memset(a1, 0, sizeof a1);
    memset(b1, 0, sizeof b1);
    memset(b, 0, sizeof b);
    for (int i = 0, __e__ = (int)(n); i < __e__; ++i) {
      scanf("%d", &val);
      for (int j = 0, __e__ = (int)(32); j < __e__; ++j)
        if (((val) & (1 << (j)))) {
          a1[j]++;
        }
    }
    for (int i = 0, __e__ = (int)(m); i < __e__; ++i) {
      scanf("%d", &val);
      b1[val]++;
    }
  }
  bool ok(int m) {
    int sum = 0;
    for (int i = 0, __e__ = (int)(32); i < __e__; ++i) {
      if (sum + b1[i] <= m) {
        sum += b1[i];
        b[i] = b1[i];
      } else {
        b[i] = (m - sum);
        sum = m;
      }
    }
    int res = 0;
    for (int i = 0, __e__ = (int)(32); i < __e__; ++i) a[i] = a1[i];
    for (int i = (31), __e__ = (0); i >= __e__; --i) {
      for (int j = (31), __e__ = (i + 1); j >= __e__; --j)
        if (a[j]) {
          a[i] += a[j] * (j - i + 1);
          a[j] = 0;
        }
      int temp = min(a[i], b[i]);
      a[i] -= temp;
      b[i] -= temp;
      res += temp;
    }
    return res == m;
  }
  void process() {
    int lo = 0;
    int hi = m;
    while (lo <= hi) {
      int mid = (lo + hi) / 2;
      if (ok(mid)) {
        res = mid;
        lo = mid + 1;
      } else {
        hi = mid - 1;
      }
    }
    out << res << endl;
  }
};
int main() {
  srand(time(0));
  initProgram();
  int ntest = 1;
  {} {
    for (int i = 0, __e__ = (int)(ntest); i < __e__; ++i) {
      cerr << "processing test: " << i + 1 << endl;
      Task *pT = new Task();
      pT->testcase = i + 1;
      pT->readInput();
      pT->process();
      cout << pT->out.str();
      delete pT;
    }
  }
}
template <class T>
inline T LOW_BIT(T n) {
  return (n ^ (n - 1)) & n;
}
template <class T>
inline int COUNT_BIT(T n) {
  return (n == 0) ? 0 : (1 + COUNT_BIT(n & (n - 1)));
}
template <class T>
inline T GCD(T a, T b) {
  if (a < 0) return GCD(-a, b);
  if (b < 0) return GCD(a, -b);
  return (b == 0) ? a : GCD(b, a % b);
}
template <class T>
inline T LCM(T a, T b) {
  if (a < 0) return LCM(-a, b);
  if (b < 0) return LCM(a, -b);
  return a * (b / GCD(a, b));
}
bool isUpperCase(char c) { return c >= 'A' && c <= 'Z'; }
bool isLowerCase(char c) { return c >= 'a' && c <= 'z'; }
bool isLetter(char c) {
  return (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z');
}
bool isDigit(char c) { return c >= '0' && c <= '9'; }
char toLowerCase(char c) { return (isUpperCase(c)) ? (c + 32) : c; }
char toUpperCase(char c) { return (isLowerCase(c)) ? (c - 32) : c; }
template <class T>
string toString(T n) {
  ostringstream ost;
  ost << n;
  ost.flush();
  return ost.str();
}
template <class T>
inline vector<pair<T, int> > factorize(T n) {
  vector<pair<T, int> > R;
  for (T i = 2; n > 1;) {
    if (n % i == 0) {
      int C = 0;
      for (; n % i == 0; C++, n /= i)
        ;
      R.push_back(make_pair(i, C));
    }
    i++;
    if (i > n / i) i = n;
  }
  if (n > 1) R.push_back(make_pair(n, 1));
  return R;
}
template <class T>
void stoa(const string &s, int &n, T A[]) {
  n = 0;
  istringstream sin(s);
  for (T v; sin >> v; A[n++] = v)
    ;
}
template <class T>
void atos(int n, T A[], string &s) {
  ostringstream sout;
  for (int i = 0; i < n; i++) {
    if (i > 0) sout << ' ';
    sout << A[i];
  }
  s = sout.str();
}
template <class T>
void atov(int n, T A[], vector<T> &vi) {
  vi.clear();
  for (int i = 0; i < n; i++) vi.push_back(A[i]);
}
template <class T>
void vtoa(const vector<T> &vi, int &n, T A[]) {
  n = vi.size();
  for (int i = 0; i < n; i++) A[i] = vi[i];
}
template <class T>
void stov(const string &s, vector<T> &vi) {
  vi.clear();
  istringstream sin(s);
  for (T v; sin >> v; vi.push_bakc(v))
    ;
}
template <class T>
void vtos(const vector<T> &vi, string &s) {
  ostringstream sout;
  for (int i = 0; i < vi.size(); i++) {
    if (i > 0) sout << ' ';
    sout << vi[i];
  }
  s = sout.str();
}
int64_t fecma_pow(int64_t a, int64_t b, int64_t MOD) {
  int64_t x = 1, y = a;
  while (b != 0) {
    if (b % 2 == 1) {
      x = (x * y);
      x %= MOD;
    }
    y = (y * y);
    y %= MOD;
    b /= 2;
  }
  return x;
}
int64_t modInverse2(int64_t a, int64_t m) {
  int64_t B = fecma_pow(a, m - 2, m);
  if (B < 0) {
    B += (abs(B) / m + 1) * m;
    B %= m;
  }
  return B;
}
template <class T>
bool check_min(T &mn, const T &val) {
  if (val < mn) {
    mn = val;
    return true;
  }
  return false;
}
template <class T>
bool check_max(T &mx, const T &val) {
  if (mx < val) {
    mx = val;
    return true;
  }
  return false;
}

```