#include<stdio.h>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define N 100100
int a[N],b[N];
int h[N];
int n,m;
int tot = 0;
inline int getint()
{
int x = 0;
char ch;
while (!isdigit(ch = getchar()));
x = x * 10 + ch - 48;
while (isdigit(ch = getchar())) x = x * 10 + ch - 48;
return x;
}
void up(int x)
{
int p = x >> 1;
while (p)
{
if (h[p] < h[x]) swap(h[p],h[x]);
else return;
x = p;
p = x >> 1;
}
return;
}
void down(int x)
{
int p = x << 1;
while (p <= tot)
{
if (h[p] < h[p+1] && p < tot) ++p;
if (h[p] > h[x]) swap(h[p],h[x]);
else return;
x = p;
p = x << 1;
}
return;
}
void push(int x)
{
h[++tot] = x;
if (tot == 1) return;
up(tot);
return;
}
void pop()
{
h[1] = h[tot--];
if (!tot) return;
down(1);
return;
}
bool can(int x)
{
memset(h,0,sizeof(h));
tot = 0;
for (int i = 1; i <= n; i++)
push(a[i]);
for (int i = x; i >= 1; i--)
{
if (tot == 0) return 0;
int tem = h[1];
pop();
if (b[i] > tem)
{
return 0;
}
else{
tem -= b[i];
push(tem);
}
}
return 1;
}
int main()
{
freopen("mushro.in","r",stdin);
freopen("mushro.out","w",stdout);
n = getint();
m = getint();
for (int i = 1; i <= n; i++)
{
a[i] = getint();
}
int l = 0,r = m,ans = 0;
for (int i = 1; i <= m; i++) b[i] = getint();
sort(b + 1, b + 1 + m);
while (l <= r)
{
int mid = (l + r) >> 1;
if (can(mid)) ans = mid,l = mid + 1;
else r = mid - 1;
}
printf("%d\n",ans);
return 0;
}