#include<bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 5;
const long long INF = 1e18;
typedef long long ll;
template <typename T> void chkmax(T &x, T y) {x = max(x, y); }
template <typename T> void chkmin(T &x, T y) {x = min(x, y); }
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
ll x[MAXN], y[MAXN]; vector <int> a[MAXN];
int n, k, ans, g[MAXN], w[MAXN], fa[MAXN];
struct BinaryIndexTree {
	int n; ll a[MAXN];
	void init(int x) {
		n = x;
		memset(a, 0, sizeof(a));
	}
	void modify(int x, ll d) {
		for (int i = x; i <= n; i += i & -i)
			a[i] += d;
	}
	ll query(int x) {
		ll ans = 0;
		for (int i = x; i >= 1; i -= i & -i)
			ans += a[i];
		return ans;
	}
} BIT;
struct SegmentTree {
	struct Node {
		int lc, rc, rev;
		ll tagh, tagc;
		ll Maxh, Minc, res;
	} a[MAXN * 2];
	int root, size, n;
	void pushdown(int root) {
		if (a[root].tagh) {
			a[a[root].lc].tagh += a[root].tagh;
			a[a[root].lc].Maxh += a[root].tagh;
			a[a[root].lc].res += a[root].tagh;
			a[a[root].rc].tagh += a[root].tagh;
			a[a[root].rc].Maxh += a[root].tagh;
			a[a[root].rc].res += a[root].tagh;
			a[root].tagh = 0;
		}
		if (a[root].tagc) {
			a[a[root].lc].tagc += a[root].tagc;
			a[a[root].lc].Minc += a[root].tagc;
			a[a[root].lc].res += a[root].tagc;
			a[a[root].rc].tagc += a[root].tagc;
			a[a[root].rc].Minc += a[root].tagc;
			a[a[root].rc].res += a[root].tagc;
			a[root].tagc = 0;
		}
	}
	ll query(int root, ll height) {
		if (a[root].lc == 0) return a[root].Minc + max(height, y[a[root].rev] + BIT.query(a[root].rev));
		else {
			pushdown(root);
			if (height <= a[a[root].lc].Maxh) return min(a[root].res, query(a[root].lc, height));
			else return min(height + a[a[root].lc].Minc, query(a[root].rc, max(height, a[a[root].lc].Maxh)));
		}
	}
	void update(int root) {
		a[root].Maxh = max(a[a[root].lc].Maxh, a[a[root].rc].Maxh);
		a[root].Minc = min(a[a[root].lc].Minc, a[a[root].rc].Minc);
		a[root].res = query(a[root].rc, a[a[root].lc].Maxh);
	}
	void build(int &root, int l, int r, ll *x) {
		root = ++size;
		if (l == r) {
			a[root].rev = l;
			a[root].Maxh = x[l];
			a[root].Minc = -x[l];
			a[root].res = 0;
			return;
		}
		int mid = (l + r) / 2;
		build(a[root].lc, l, mid, x);
		build(a[root].rc, mid + 1, r, x);
		update(root);
	}
	void init(int l, ll *x) {
		root = size = 0, n = l;
		build(root, 1, n, x);
	}
	void addheight(int root, int l, int r, int ql, int qr, ll d) {
		if (l == ql && r == qr) {
			a[root].tagh += d;
			a[root].Maxh += d;
			a[root].res += d;
			return;
		}
		pushdown(root);
		int mid = (l + r) / 2;
		if (mid >= ql) addheight(a[root].lc, l, mid, ql, min(mid, qr), d);
		if (mid + 1 <= qr) addheight(a[root].rc, mid + 1, r, max(mid + 1, ql), qr, d);
		update(root);
	}
	void addheight(int l, int r, ll d) {
		addheight(root, 1, n, l, r, d);
	}
	int home; ll Max, Mem;
	void dfs(int root, int l, int r, int pos, ll Lim) {
		if (pos <= l) {
			if (query(root, Max) <= Lim) {
				home = root;
				Mem = Max;
			}
			chkmax(Max, a[root].Maxh);
			return;
		}
		pushdown(root);
		int mid = (l + r) / 2;
		if (pos <= mid) dfs(a[root].lc, l, mid, pos, Lim);
		dfs(a[root].rc, mid + 1, r, pos, Lim);
	}
	int getans(int root, ll height, ll Lim) {
		if (a[root].lc == 0) return a[root].rev;
		pushdown(root);
		if (query(a[root].rc, max(height, a[a[root].lc].Maxh)) <= Lim) return getans(a[root].rc, max(height, a[a[root].lc].Maxh), Lim);
		else return getans(a[root].lc, height, Lim);
	}
	int getans(int pos, ll Lim) {
		Max = BIT.query(pos) + y[pos];
		dfs(root, 1, n, pos, Lim);
		return getans(home, Mem, Lim);
	}
} ST;
void dfs(int pos, int fa) {
	chkmax(ans, ST.getans(pos, k) - pos + 1);
	for (auto p : a[pos]) {
		BIT.modify(pos, x[p] - x[pos]);
		ST.addheight(pos - 1, n, x[p] - x[pos]);
		dfs(p, pos);
		BIT.modify(pos, x[pos] - x[p]);
		ST.addheight(pos - 1, n, x[pos] - x[p]);
	}
}
int main() {
	read(n), read(k);
	for (int i = 1; i <= n - 1; i++)
		read(w[i]);
	for (int i = 1; i <= n; i++)
		read(g[i]);
	y[1] = g[1];
	for (int i = 2; i <= n; i++) {
		x[i] = y[i - 1] - w[i - 1];
		y[i] = x[i] + g[i];
	}
	static int q[MAXN]; int top = 0;
	for (int i = n; i >= 1; i--) {
		while (top >= 1 && x[i] <= x[q[top]]) top--;
		if (top >= 1) {
			fa[i] = q[top];
			a[q[top]].push_back(i);
		}
		q[++top] = i;
	}
	BIT.init(n);
	ST.init(n, y);
	for (int i = 1; i <= n; i++)
		if (fa[i] == 0) dfs(i, 0);
	cout << ans << endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

inline int gi()
{
	char c = getchar();
	while (c < '0' || c > '9') c = getchar();
	int sum = 0;
	while ('0' <= c && c <= '9') sum = sum * 10 + c - 48, c = getchar();
	return sum;
}

typedef long long ll;
const int maxn = 100005;

int n, lim, ans;
ll w[maxn], g[maxn], pre[maxn], suf[maxn];
int top, stk[maxn], nxt[maxn];

struct edge
{
	int to, next;
} e[maxn * 2];
int h[maxn], tot;

inline void add(int u, int v)
{
	e[++tot] = (edge) {v, h[u]};
	h[u] = tot;
}

ll mp[maxn << 2], sp[maxn << 2];
ll ms[maxn << 2], tag[maxn << 2];

void build(int s, int l, int r);
void insert(int s, int l, int r, int ql, int qr, ll t);
inline void update(int s, int l, int r);
inline void pushdown(int s);
inline void modify(int s, ll v);
ll calc(int s, int l, int r, ll t);
int query(int s, int l, int r, ll t);
int solve(int s, int l, int r, ll t);

void dfs(int u)
{
	stk[++top] = u;
	if (u != n + 1) {
		insert(1, 1, n, 1, u - 1, -1e17);
		insert(1, 1, n, nxt[u] - 1, n, pre[u - 1] - pre[nxt[u] - 1]);
		int l = 1, r = top, mid;
		while (l < r) {
			mid = (l + r) >> 1;
			if (pre[u - 1] - pre[stk[mid] - 1] <= lim) r = mid;
			else l = mid + 1;
		}
		insert(1, 1, n, stk[l - 1], n, 1e17);
		ans = max(ans, query(1, 1, n, -1e17) - u + 1);
		insert(1, 1, n, stk[l - 1], n, -1e17);
		insert(1, 1, n, 1, u - 1, 1e17);
	}
	for (int i = h[u], v; v = e[i].to, i; i = e[i].next)
		if (v) dfs(v);
	if (u != n + 1) insert(1, 1, n, nxt[u] - 1, n, -pre[u - 1] + pre[nxt[u] - 1]);
}

#define mid ((l + r) >> 1)
#define lch (s << 1)
#define rch (s << 1 | 1)

void build(int s, int l, int r)
{
	if (l == r) return ms[s] = suf[l], mp[s] = -suf[l], void();
	build(lch, l, mid);
	build(rch, mid + 1, r);
	update(s, l, r);
	mp[s] = min(mp[lch], mp[rch]);
}

void insert(int s, int l, int r, int ql, int qr, ll t)
{
	if (ql > qr) return ;
	if (ql <= l && r <= qr) return modify(s, t), void();
	pushdown(s);
	if (ql <= mid) insert(lch, l, mid, ql, qr, t);
	if (qr > mid) insert(rch, mid + 1, r, ql, qr, t);
	update(s, l, r);
}

inline void update(int s, int l, int r)
{
	ms[s] = max(ms[lch], ms[rch]);
	sp[s] = calc(rch, mid + 1, r, ms[lch]);
}

inline void pushdown(int s)
{
	if (!tag[s]) return ;
	modify(lch, tag[s]); modify(rch, tag[s]);
	tag[s] = 0;
}

inline void modify(int s, ll v)
{
	tag[s] += v; ms[s] += v; sp[s] += v;
}

ll calc(int s, int l, int r, ll t)
{
	if (l == r) return t + mp[s];
	pushdown(s);
	if (ms[lch] >= t) return min(calc(lch, l, mid, t), sp[s]);
	else return min(t + mp[lch], calc(rch, mid + 1, r, t));
}

int query(int s, int l, int r, ll t)
{
	if (l == r) return t + mp[s] <= lim ? l : 0;
	pushdown(s);
	if (ms[lch] >= t) {
		if (sp[s] <= lim) return query(rch, mid + 1, r, ms[lch]);
		else return query(lch, l, mid, t);
	} else return max(solve(lch, l, mid, t), query(rch, mid + 1, r, t));
}

int solve(int s, int l, int r, ll t)
{
	if (l == r) return t + mp[s] <= lim ? l : 0;
	pushdown(s);
	if (t + mp[rch] <= lim) return solve(rch, mid + 1, r, t);
	else return solve(lch, l, mid, t);
}

int main()
{
	n = gi(); lim = gi();
	for (int i = 1; i < n; ++i) w[i] = gi();
	w[n] = 1e17;
	for (int i = 1; i <= n; ++i) g[i] = gi();
	for (int i = 1; i <= n; ++i) pre[i] = pre[i - 1] + g[i] - w[i], suf[i] = suf[i - 1] + g[i] - w[i - 1];

	stk[top] = n + 1;
	for (int i = n; i >= 1; --i) {
		while (top && pre[stk[top] - 1] >= pre[i - 1]) --top;
		add(nxt[i] = stk[top], i);
		stk[++top] = i;
	}

	build(1, 1, n);
	top = 0; dfs(n + 1);

	printf("%d\n", ans);

	return 0;
}


#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cctype>
#include <vector>
using namespace std;

namespace zyt
{
	template<typename T>
	inline bool read(T &x)
	{
		char c;
		bool f = false;
		x = 0;
		do
			c = getchar();
		while (c != EOF && c != '-' && !isdigit(c));
		if (c == EOF)
			return false;
		if (c == '-')
			f = true, c = getchar();
		do
			x = x * 10 + c - '0', c = getchar();
		while (isdigit(c));
		if (f)
			x = -x;
		return true;
	}
	template<typename T>
	inline void write(T x)
	{
		static char buf[20];
		char *pos = buf;
		if (x < 0)
			putchar('-'), x = -x;
		do
			*pos++ = x % 10 + '0';
		while (x /= 10);
		while (pos > buf)
			putchar(*--pos);
	}
	typedef long long ll;
	const int N = 1e5 + 10;
	const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
	ll pre[N], suf[N], w[N], g[N];;
	int nxt[N], n, k, ans;
	vector<int> s[N];
	namespace Segment_Tree
	{
		struct node
		{
			ll minp, maxs, ans, tag;
		} tree[N << 2];
		void add(const int rot, const ll x)
		{
			tree[rot].maxs += x;
			tree[rot].ans += x;
			tree[rot].tag += x;
		}
		void pushdown(const int rot)
		{
			if (tree[rot].tag)
			{
				add(rot << 1, tree[rot].tag);
				add(rot << 1 | 1, tree[rot].tag);
				tree[rot].tag = 0;
			}
		}
		ll dfs(const int rot, const int lt, const int rt, const ll mx)
		{
			if (lt == rt)
				return mx + tree[rot].minp;
			int mid = (lt + rt) >> 1;
			pushdown(rot);
			if (tree[rot << 1].maxs <= mx)
				return min(mx + tree[rot << 1].minp, dfs(rot << 1 | 1, mid + 1, rt, mx));
			else
				return min(tree[rot].ans, dfs(rot << 1, lt, mid, mx));
		}
		void update(const int rot, const int lt, const int rt)
		{
			tree[rot].minp = min(tree[rot << 1].minp, tree[rot << 1 | 1].minp);
			tree[rot].maxs = max(tree[rot << 1].maxs, tree[rot << 1 | 1].maxs);
			int mid = (lt + rt) >> 1;
			tree[rot].ans = dfs(rot << 1 | 1, mid + 1, rt, tree[rot << 1].maxs);
		}
		void build(const int rot, const int lt, const int rt)
		{
			if (lt == rt)
			{
				tree[rot].minp = -suf[lt];
				tree[rot].maxs = suf[lt];
				tree[rot].ans = 0;
				return;
			}
			int mid = (lt + rt) >> 1;
			build(rot << 1, lt, mid), build(rot << 1 | 1, mid + 1, rt);
			update(rot, lt, rt);
		}
		void add(const int rot, const int lt, const int rt, const int ls, const int rs, const ll x)
		{
			if (ls <= lt && rt <= rs)
				return void(add(rot, x));
			int mid = (lt + rt) >> 1;
			pushdown(rot);
			if (ls <= mid)
				add(rot << 1, lt, mid, ls, rs, x);
			if (rs > mid)
				add(rot << 1 | 1, mid + 1, rt, ls, rs, x);
			update(rot, lt, rt);
		}
		int find(const int rot, const int lt, const int rt, const ll mx)
		{
			if (lt == rt)
				return mx + tree[rot].minp <= k ? lt : 0;
			int mid = (lt + rt) >> 1;
			pushdown(rot);
			if (mx + tree[rot << 1 | 1].minp <= k)
				return find(rot << 1 | 1, mid + 1, rt, mx);
			else
				return find(rot << 1, lt, mid, mx);
		}
		int query(const int rot, const int lt, const int rt, const ll mx)
		{
			if (lt == rt)
				return mx + tree[rot].minp <= k ? lt : 0;
			int mid = (lt + rt) >> 1;
			pushdown(rot);
			if (tree[rot << 1].maxs <= mx)
			{
				int ans = 0;
				ans = max(ans, query(rot << 1 | 1, mid + 1, rt, mx));
				if (!ans && mx + tree[rot << 1].minp <= k)
					ans = max(ans, find(rot << 1, lt, mid, mx));
				return ans;
			}
			else
			{
				if (tree[rot].ans <= k)
					return query(rot << 1 | 1, mid + 1, rt, tree[rot << 1].maxs);
				else
					return query(rot << 1, lt, mid, mx);
			}
		}
	}
	int sta[N], top;
	int find(const int u)
	{
		int l = 0, r = top - 1, ans;
		while (l <= r)
		{
			int mid = (l + r) >> 1;
			if (pre[u - 1] - pre[sta[mid] - 1] <= k)
				r = mid - 1, ans = mid;
			else
				l = mid + 1;
		}
		return sta[ans - 1] - 1;
	}
	void dfs(const int u)
	{
		using Segment_Tree::add;
		using Segment_Tree::query;
		sta[top++] = u;
		if (nxt[u] <= n)
			add(1, 1, n, nxt[u] - 1, n, pre[u - 1] - pre[nxt[u] - 1]);
		if (u <= n)
		{
			int lim = find(u);
			if (u > 1)
				add(1, 1, n, 1, u - 1, -LINF);
			if (lim < n)
				add(1, 1, n, lim, n, LINF);
			ans = max(ans, query(1, 1, n, -LINF) - u + 1);
			if (lim < n)
				add(1, 1, n, lim, n, -LINF);
			if (u > 1)
				add(1, 1, n, 1, u - 1, LINF);
		}
		for (auto v : s[u])
			dfs(v);
		if (nxt[u] <= n)
			add(1, 1, n, nxt[u] - 1, n, pre[nxt[u] - 1] - pre[u - 1]);
		--top;
	}
	int work()
	{
		read(n), read(k);
		for (int i = 1; i < n; i++)
			read(w[i]);
		w[n] = LINF;
		for (int i = 1; i <= n; i++)
			read(g[i]);
		for (int i = 1; i <= n; i++)
		{
			pre[i] = pre[i - 1] + g[i] - w[i];
			suf[i] = suf[i - 1] + g[i] - w[i - 1];
			while (top && pre[sta[top - 1] - 1] > pre[i - 1])
				nxt[sta[--top]] = i;
			sta[top++] = i;
		}
		while (top)
			nxt[sta[--top]] = n + 1;
		nxt[n + 1] = n + 1;
		for (int i = 1; i <= n; i++)
			s[nxt[i]].push_back(i);
		Segment_Tree::build(1, 1, n);
		dfs(n + 1);
		write(ans);
		return 0;
	}
}
int main()
{
	return zyt::work();
}


#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cctype>
#include <vector>
using namespace std;

namespace zyt
{
	template<typename T>
	inline bool read(T &x)
	{
		char c;
		bool f = false;
		x = 0;
		do
			c = getchar();
		while (c != EOF && c != '-' && !isdigit(c));
		if (c == EOF)
			return false;
		if (c == '-')
			f = true, c = getchar();
		do
			x = x * 10 + c - '0', c = getchar();
		while (isdigit(c));
		if (f)
			x = -x;
		return true;
	}
	template<typename T>
	inline void write(T x)
	{
		static char buf[20];
		char *pos = buf;
		if (x < 0)
			putchar('-'), x = -x;
		do
			*pos++ = x % 10 + '0';
		while (x /= 10);
		while (pos > buf)
			putchar(*--pos);
	}
	typedef long long ll;
	const int N = 1e5 + 10;
	const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
	ll pre[N], suf[N], w[N], g[N];;
	int nxt[N], n, k, ans;
	vector<int> s[N];
	namespace Segment_Tree
	{
		struct node
		{
			ll minp, maxs, ans, tag;
		} tree[N << 2];
		void add(const int rot, const ll x)
		{
			tree[rot].maxs += x;
			tree[rot].ans += x;
			tree[rot].tag += x;
		}
		void pushdown(const int rot)
		{
			if (tree[rot].tag)
			{
				add(rot << 1, tree[rot].tag);
				add(rot << 1 | 1, tree[rot].tag);
				tree[rot].tag = 0;
			}
		}
		ll dfs(const int rot, const int lt, const int rt, const ll mx)
		{
			if (lt == rt)
				return mx + tree[rot].minp;
			int mid = (lt + rt) >> 1;
			pushdown(rot);
			if (tree[rot << 1].maxs <= mx)
				return min(mx + tree[rot << 1].minp, dfs(rot << 1 | 1, mid + 1, rt, mx));
			else
				return min(tree[rot].ans, dfs(rot << 1, lt, mid, mx));
		}
		void update(const int rot, const int lt, const int rt)
		{
			tree[rot].minp = min(tree[rot << 1].minp, tree[rot << 1 | 1].minp);
			tree[rot].maxs = max(tree[rot << 1].maxs, tree[rot << 1 | 1].maxs);
			int mid = (lt + rt) >> 1;
			tree[rot].ans = dfs(rot << 1 | 1, mid + 1, rt, tree[rot << 1].maxs);
		}
		void build(const int rot, const int lt, const int rt)
		{
			if (lt == rt)
			{
				tree[rot].minp = -suf[lt];
				tree[rot].maxs = suf[lt];
				tree[rot].ans = 0;
				return;
			}
			int mid = (lt + rt) >> 1;
			build(rot << 1, lt, mid), build(rot << 1 | 1, mid + 1, rt);
			update(rot, lt, rt);
		}
		void add(const int rot, const int lt, const int rt, const int ls, const int rs, const ll x)
		{
			if (ls <= lt && rt <= rs)
				return void(add(rot, x));
			int mid = (lt + rt) >> 1;
			pushdown(rot);
			if (ls <= mid)
				add(rot << 1, lt, mid, ls, rs, x);
			if (rs > mid)
				add(rot << 1 | 1, mid + 1, rt, ls, rs, x);
			update(rot, lt, rt);
		}
		int find(const int rot, const int lt, const int rt, const ll mx)
		{
			if (lt == rt)
				return mx + tree[rot].minp <= k ? lt : 0;
			int mid = (lt + rt) >> 1;
			pushdown(rot);
			if (mx + tree[rot << 1 | 1].minp <= k)
				return find(rot << 1 | 1, mid + 1, rt, mx);
			else
				return find(rot << 1, lt, mid, mx);
		}
		int query(const int rot, const int lt, const int rt, const ll mx)
		{
			if (lt == rt)
				return mx + tree[rot].minp <= k ? lt : 0;
			int mid = (lt + rt) >> 1;
			pushdown(rot);
			if (tree[rot << 1].maxs <= mx)
			{
				int ans = 0;
				ans = max(ans, query(rot << 1 | 1, mid + 1, rt, mx));
				if (!ans && mx + tree[rot << 1].minp <= k)
					ans = max(ans, find(rot << 1, lt, mid, mx));
				return ans;
			}
			else
			{
				if (tree[rot].ans <= k)
					return query(rot << 1 | 1, mid + 1, rt, tree[rot << 1].maxs);
				else
					return query(rot << 1, lt, mid, mx);
			}
		}
	}
	int sta[N], top;
	int find(const int u)
	{
		int l = 0, r = top - 1, ans;
		while (l <= r)
		{
			int mid = (l + r) >> 1;
			if (pre[u - 1] - pre[sta[mid] - 1] <= k)
				r = mid - 1, ans = mid;
			else
				l = mid + 1;
		}
		return sta[ans - 1] - 1;
	}
	void dfs(const int u)
	{
		using Segment_Tree::add;
		using Segment_Tree::query;
		sta[top++] = u;
		if (nxt[u] <= n)
			add(1, 1, n, nxt[u] - 1, n, pre[u - 1] - pre[nxt[u] - 1]);
		if (u <= n)
		{
			int lim = find(u);
			if (u > 1)
				add(1, 1, n, 1, u - 1, -LINF);
			if (lim < n)
				add(1, 1, n, lim, n, -LINF);
			ans = max(ans, query(1, 1, n, -LINF) - u + 1);
			if (lim < n)
				add(1, 1, n, lim, n, LINF);
			if (u > 1)
				add(1, 1, n, 1, u - 1, LINF);
		}
		for (auto v : s[u])
			dfs(v);
		if (nxt[u] <= n)
			add(1, 1, n, nxt[u] - 1, n, pre[nxt[u] - 1] - pre[u - 1]);
		--top;
	}
	int work()
	{
		read(n), read(k);
		for (int i = 1; i < n; i++)
			read(w[i]);
		w[n] = LINF;
		for (int i = 1; i <= n; i++)
			read(g[i]);
		for (int i = 1; i <= n; i++)
		{
			pre[i] = pre[i - 1] + g[i] - w[i];
			suf[i] = suf[i - 1] + g[i] - w[i - 1];
			while (top && pre[sta[top - 1] - 1] > pre[i - 1])
				nxt[sta[--top]] = i;
			sta[top++] = i;
		}
		while (top)
			nxt[sta[--top]] = n + 1;
		nxt[n + 1] = n + 1;
		for (int i = 1; i <= n; i++)
			s[nxt[i]].push_back(i);
		Segment_Tree::build(1, 1, n);
		dfs(n + 1);
		write(ans);
		return 0;
	}
}
int main()
{
	return zyt::work();
}


/*
	令s_i = \sum -g_j + w_j - g_i
	那么最后的答案就是max(s_i | l <= s_i <= r) - s_r + c_r <= k
	每次给区间加x

	我们二分一个j之后，每次维护的就是一个后缀[j..n]的min( max(s_i) - s_r + c_r )
	先考虑对区间维护这个东西，这个信息本身并不区间可加
	但是你注意max(s_i)生效的是一个前缀和区间，我们可以二分出这个区间，就像区间上升序列线段树一样合并

	然后我们二分j的时候必须线段树上二分来保证复杂度

	线段树上要维护 1.max(si) 2.c_i - s_i的最小值 3.max(s_i) + c_r - s_r的最小值 4.右儿子对3的贡献

	标记是区间+d, 它对1影响是+d, 对2没有影响，对3影响是+d，对4影响也是+d

	然后需要注意我们算的是从走过i这条边之后开始下一次卡住的位置

	所以如果i自己出发就被卡住，算答案之前要算一下自己的g加的多少
*/

#include <iostream>
#include <cstdio>
#include <map>
#include <set>
#include <queue>
#include <vector>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#define rep(i,a,b) for(int i = a; i <= b; i++)
#define dep(i,a,b) for(int i = a; i >= b; i--)
#define Rep(i,a) for(int i = 0; i < a; i++)
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define ab(x) ((x) < 0 ? -(x) : (x))
using namespace std;
typedef long long LL;
typedef map<int, int>::iterator mit;
typedef set<int>::iterator sit;
typedef pair<int, int> pii;
#define x first
#define y second

const int N = 1e5 + 10;

struct node { LL mxs, mncs, mnscs, rs, d; }T[N << 2];

#define o T[x]
#define mid ((l + r) >> 1)
#define lc (x << 1)
#define rc (lc | 1)
#define lcq lc, l, mid
#define rcq rc, mid + 1, r
void push(int x, int l, int r) {
	if (o.d) {
		o.mxs += o.d, o.mnscs += o.d, o.rs += o.d;
		if (l < r) T[lc].d += o.d, T[rc].d += o.d;
		o.d = 0;
	}
}

LL cal(int x, int l, int r, LL y) {
	push(x, l, r);
	if (l == r || y >= o.mxs) return y + o.mncs;
	push(lcq), push(rcq);
	if (y <= T[lc].mxs) return max(cal(lcq, y), o.rs);
	else return max(cal(lcq, y), cal(rcq, y));
}

void upd(int x, int l, int r) {
	o.mxs = max(T[lc].mxs, T[rc].mxs);
	o.mncs = min(T[lc].mncs, T[rc].mncs);
	o.mnscs = min(T[lc].mnscs, o.rs = cal(rcq, T[lc].mxs));
}

int a, b; LL c;
int d[N];
void add(int x, int l, int r) {
/*
	if (x == 1) {
		rep(i,a,b) d[i] += c;
		return;
	}*/

	if (a <= l && r <= b) o.d += c, push(x, l, r);
	else {
		push(x, l, r);
		if (a <= mid) add(lcq); else push(lcq);
		if (b >  mid) add(rcq); else push(rcq);
		upd(x, l, r);
	}
}

const LL inf = 1LL << 60;

int n, k, w[N], g[N];
LL sum[N], suf[N], val[N];
void build(int x, int l, int r) {
	if (l == r) o.mxs = suf[l], o.mncs = -suf[l], o.mnscs = inf;
	else build(lcq), build(rcq), upd(x, l, r);
}

vector<int> son[N];
int nxt[N], go[N][20], f[N][20];

void init() {
	rep(i,1,n - 1) sum[i] = sum[i - 1] + g[i] - w[i];
	static int st[N]; int top = 0;
	fill(nxt + 1, nxt + n + 1, n);
	rep(i,1,n - 1) {
		while (top && sum[st[top]] > sum[i]) nxt[st[top--]] = i;
		st[++top] = i;
	}
	rep(i,1,n) suf[i] = suf[i - 1] - w[i - 1] + g[i];
	rep(i,1,n) val[i] = (nxt[i] < n) ? sum[i] - sum[nxt[i]] : 0;
	rep(i,1,n - 1) son[nxt[i]].pb(i);

	rep(i,1,n - 1) go[i][0] = nxt[i], f[i][0] = val[i];
	rep(j,1,16)
		rep(i,1,n - 1)
			go[i][j] = go[go[i][j - 1]][j - 1], f[i][j] = f[i][j - 1] + f[go[i][j - 1]][j - 1];
}

int ans = 1;

LL mx(int x, int l, int r) {
	push(x, l, r);
	if (a <= l && r <= b) return o.mxs;
	else return max((a <= mid ? mx(lcq) : -inf), (b > mid ? mx(rcq) : -inf));
}

int qry(int x, int l, int r, LL y) {
/*
	if (x == 1) {
		dep(i,b,a) {
			LL mx = -inf;
			rep(j,a,i - 1) mx = max(mx, 1LL * suf[j] + d[j]);
			if (mx - suf[i] <= k) return i;
		}
		return 0;
	}*/

	push(x, l, r);
   	if (a <= l && r <= b) {
		if (l == r) return (y + o.mncs <= k) ? l : 0;
		else {
			push(lcq), push(rcq);
			if (cal(rcq, max(y, T[lc].mxs)) <= k) return qry(rcq, max(y, T[lc].mxs));
			else return qry(lcq, y);
		}
	} else {
		if (b > mid) { int t = qry(rcq, max((a <= mid ? mx(lcq) : -inf), y)); if (t) return t; }
		if (a <= mid) return qry(lcq, y);
		return 0;
	}
}

int mxr(int x) {
	int cost = 0;
	dep(j,16,0) if (go[x][j] && cost + f[x][j] <= k)
		x = go[x][j], cost += f[x][j];
	if (x < n) x = nxt[x];
	return x;
}

void dfs(int x) {
	if (nxt[x] < n) a = nxt[x], b = n, c = val[x], add(1, 1, n);

	if (x < n) {
		a = x + 1, b = n; int t = qry(1, 1, n, -inf);
		if (t) ans = max(ans, min(mxr(x), t) - x);
	}

	int len = son[x].size(); Rep(i,len) dfs(son[x][i]);

	if (nxt[x] < n) a = nxt[x], b = n, c = -val[x], add(1, 1, n);
}
int main() {
	scanf("%d%d",&n,&k);
	rep(i,1,n - 1) scanf("%d",w + i);
	rep(i,1,n) scanf("%d",g + i);
	n++;
	dep(i,n,2) g[i] = g[i - 1];
	dep(i,n-1,2) w[i] = w[i - 1];
	g[1] = 0, w[1] = k + 1;

	init(), build(1, 1, n);
	dfs(n);
	printf("%d\n",ans);
	return 0;
}


#include <iostream>
#include <cstdio>
#include <map>
#include <set>
#include <queue>
#include <vector>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#define rep(i,a,b) for(int i = a; i <= b; i++)
#define dep(i,a,b) for(int i = a; i >= b; i--)
#define Rep(i,a) for(int i = 0; i < a; i++)
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define ab(x) ((x) < 0 ? -(x) : (x))
using namespace std;
typedef long long LL;
typedef map<int, int>::iterator mit;
typedef set<int>::iterator sit;
typedef pair<int, int> pii;
#define x first
#define y second
const LL inf = 1LL << 60;
const int N = 1e5 + 10;
#define mid ((l + r) >> 1)
int n, k, w[N], g[N];

LL Sw[N], Sg[N];
LL s1[N], s2[N];
struct sta{ LL mx[3]; } T[N << 2];
sta operator + (const sta &a, const sta &b) {
	sta c;
	Rep(d,3) c.mx[d] = max(a.mx[d], b.mx[d]);
	c.mx[2] = max(c.mx[2], a.mx[0] + b.mx[1]);
	return c;
}
namespace seg {
	#define lc (x << 1)
	#define rc (lc | 1)
	#define mid ((l + r) >> 1)
	#define lcq lc, l, mid
	#define rcq rc, mid + 1, r
	void build(int x, int l, int r) {
		if (l == r) T[x] = (sta){s1[l], s2[l], s1[l] + s2[l]};
		else build(lcq), build(rcq), T[x] = T[lc] + T[rc];
	}
	int a, b;
	sta qry(int x, int l, int r) {
		if (a <= l && r <= b) return T[x];
		else {
			sta t = (sta){-inf, -inf, -inf};
			if (a <= mid) t = t + qry(lcq);
			if (b >  mid) t = t + qry(rcq);
			return t;
		}
	}
}

bool check(int L) {
	rep(i,1,n - 1) Sw[i] = Sw[i - 1] + w[i];
	rep(i,1,n) Sg[i] = Sg[i - 1] + g[i];

	LL s = 0; rep(i,1,n) s -= g[i], s2[i] = s, s += w[i];
	rep(i,1,n - 1) s1[i] = s1[i - 1] + g[i] - w[i];

	rep(i,1,n) s1[i] = -s1[i], s2[i] = -s2[i];

	seg::build(1, 1, n);

	rep(i,1,n - L + 1) {
		seg::a = i, seg::b = i + L - 2;
		sta t = seg::qry(1, 1, n);
		LL mnW = max(max(t.mx[2], t.mx[0] + s2[i + L - 1]), t.mx[1] + s1[i - 1]);
		LL sum = k - (Sw[i + L - 2] - Sw[i - 1]) + (Sg[i + L - 1] - Sg[i - 1]);
		if (sum >= mnW) return true;
	}
	return false;
}

int main() {
	scanf("%d%d",&n,&k);
	rep(i,1,n - 1) scanf("%d",w + i);
	rep(i,1,n) scanf("%d",g + i);
	int l = 1, r = n + 1;
	while (l + 1 < r) if (check(mid)) l = mid; else r = mid;
	printf("%d\n",l);
	return 0;
}


/*
	令s_i = \sum -g_j + w_j - g_i
	那么最后的答案就是max(s_i | l <= s_i <= r) - s_r + c_r <= k
	每次给区间加x

	我们二分一个j之后，每次维护的就是一个后缀[j..n]的min( max(s_i) - s_r + c_r )
	先考虑对区间维护这个东西，这个信息本身并不区间可加
	但是你注意max(s_i)生效的是一个前缀和区间，我们可以二分出这个区间，就像区间上升序列线段树一样合并

	然后我们二分j的时候必须线段树上二分来保证复杂度

	线段树上要维护 1.max(si) 2.c_i - s_i的最小值 3.max(s_i) + c_r - s_r的最小值 4.右儿子对3的贡献

	标记是区间+d, 它对1影响是+d, 对2没有影响，对3影响是+d，对4影响也是+d

	然后需要注意我们算的是从走过i这条边之后开始下一次卡住的位置

	所以如果i自己出发就被卡住，算答案之前要算一下自己的g加的多少
*/

#include <iostream>
#include <cstdio>
#include <map>
#include <set>
#include <queue>
#include <vector>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#define rep(i,a,b) for(int i = a; i <= b; i++)
#define dep(i,a,b) for(int i = a; i >= b; i--)
#define Rep(i,a) for(int i = 0; i < a; i++)
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define ab(x) ((x) < 0 ? -(x) : (x))
using namespace std;
typedef long long LL;
typedef map<int, int>::iterator mit;
typedef set<int>::iterator sit;
typedef pair<int, int> pii;
#define x first
#define y second

const int N = 1e5 + 10;

struct node { LL mxs, mncs, rs, d; }T[N << 2];

#define o T[x]
#define mid ((l + r) >> 1)
#define lc (x << 1)
#define rc (lc | 1)
#define lcq lc, l, mid
#define rcq rc, mid + 1, r
void push(int x, int l, int r) {
	if (o.d) {
		o.mxs += o.d, o.rs += o.d;
		if (l < r) T[lc].d += o.d, T[rc].d += o.d;
		o.d = 0;
	}
}

LL cal(int x, int l, int r, LL y) { //calc mnscs !!!min!!!!
	push(x, l, r);
	if (l == r || y >= o.mxs) return y + o.mncs;
	push(lcq), push(rcq);
	if (y <= T[lc].mxs) return min(cal(lcq, y), o.rs);
	else return min(cal(lcq, y), cal(rcq, y));
}

void upd(int x, int l, int r) {
	o.mxs = max(T[lc].mxs, T[rc].mxs);
	o.mncs = min(T[lc].mncs, T[rc].mncs);
	o.rs = cal(rcq, T[lc].mxs);
}

int a, b; LL c;
void add(int x, int l, int r) {
	push(x, l, r);
	if (a <= l && r <= b) o.d += c, push(x, l, r);
	else {
		push(x, l, r);
		if (a <= mid) add(lcq); else push(lcq);
		if (b >  mid) add(rcq); else push(rcq);
		upd(x, l, r);
	}
}

const LL inf = 1LL << 60;

int n, k, w[N], g[N];
LL sum[N], suf[N], val[N];
void build(int x, int l, int r) {
	if (l == r) o.mxs = suf[l], o.mncs = -suf[l], o.rs = inf;
	else build(lcq), build(rcq), upd(x, l, r);
}

vector<int> son[N];
int nxt[N], go[N][20];
LL f[N][20];

void init() {
	rep(i,1,n - 1) sum[i] = sum[i - 1] + g[i] - w[i];
	static int st[N]; int top = 0;
	fill(nxt + 1, nxt + n + 1, n);
	rep(i,1,n - 1) {
		while (top && sum[st[top]] > sum[i]) nxt[st[top--]] = i;
		st[++top] = i;
	}
	rep(i,1,n) suf[i] = suf[i - 1] - w[i - 1] + g[i];
	rep(i,1,n) val[i] = (nxt[i] < n) ? sum[i] - sum[nxt[i]] : 0;
	rep(i,1,n - 1) son[nxt[i]].pb(i);

	rep(i,1,n - 1) go[i][0] = nxt[i], f[i][0] = val[i];
	rep(j,1,16) rep(i,1,n - 1)
		go[i][j] = go[go[i][j - 1]][j - 1], f[i][j] = f[i][j - 1] + f[go[i][j - 1]][j - 1];
}

int ans = 1;

LL mx(int x, int l, int r) {
	push(x, l, r);
	if (a <= l && r <= b) return o.mxs;
	else return max((a <= mid ? mx(lcq) : -inf), (b > mid ? mx(rcq) : -inf));
}

int qry(int x, int l, int r, LL y) {
	push(x, l, r);
   	if (a <= l && r <= b) {
   		if (cal(x, l, r, y) > k) return 0;
		if (l == r) return l;
		else {
			push(lcq), push(rcq);
			int t = qry(rcq, max(y, T[lc].mxs));
			if (t) return t; else return qry(lcq, y);
		}
	} else {
		if (b > mid) {
			LL y1 = max((a <= mid) ? mx(lcq) : -inf, y);
			int t = qry(rcq, y1);
			if (t) return t;
		}
		if (a <= mid) {
			int t = qry(lcq, y);
			return t;
		}
		return 0;
	}
}

int mxr(int x) {
	LL cost = 0;
	dep(j,16,0) if (go[x][j] && cost + f[x][j] <= k)
		cost += f[x][j], x = go[x][j];
	if (x < n) x = nxt[x];
	return x;
}

void dfs(int x) {
	if (nxt[x] < n) a = nxt[x], b = n, c = val[x], add(1, 1, n);

	if (x < n) {
		int t1 = mxr(x);
		a = x + 1, b = t1; int t = qry(1, 1, n, -inf);
		if (t) ans = max(ans, t - x);
	}

	int len = son[x].size(); Rep(i,len) dfs(son[x][i]);

	if (nxt[x] < n) a = nxt[x], b = n, c = -val[x], add(1, 1, n);
}
int main() {
	scanf("%d%d",&n,&k);
	rep(i,1,n - 1) scanf("%d",w + i);
	rep(i,1,n) scanf("%d",g + i);
	n++;
	dep(i,n,2) g[i] = g[i - 1];
	dep(i,n-1,2) w[i] = w[i - 1];
	g[1] = 0, w[1] = k + 1;

	init(), build(1, 1, n);
	dfs(n);
	printf("%d\n",ans);
	return 0;
}


/*
	令s_i = \sum -g_j + w_j - g_i
	那么最后的答案就是max(s_i | l <= s_i <= r) - s_r + c_r <= k
	每次给区间加x

	我们二分一个j之后，每次维护的就是一个后缀[j..n]的min( max(s_i) - s_r + c_r )
	先考虑对区间维护这个东西，这个信息本身并不区间可加
	但是你注意max(s_i)生效的是一个前缀和区间，我们可以二分出这个区间，就像区间上升序列线段树一样合并

	然后我们二分j的时候必须线段树上二分来保证复杂度

	线段树上要维护 1.max(si) 2.c_i - s_i的最小值 3.max(s_i) + c_r - s_r的最小值 4.右儿子对3的贡献

	标记是区间+d, 它对1影响是+d, 对2没有影响，对3影响是+d，对4影响也是+d

	然后需要注意我们算的是从走过i这条边之后开始下一次卡住的位置

	所以如果i自己出发就被卡住，算答案之前要算一下自己的g加的多少
*/

#include <iostream>
#include <cstdio>
#include <map>
#include <set>
#include <queue>
#include <vector>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#define rep(i,a,b) for(int i = a; i <= b; i++)
#define dep(i,a,b) for(int i = a; i >= b; i--)
#define Rep(i,a) for(int i = 0; i < a; i++)
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define ab(x) ((x) < 0 ? -(x) : (x))
using namespace std;
typedef long long LL;
typedef map<int, int>::iterator mit;
typedef set<int>::iterator sit;
typedef pair<int, int> pii;
#define x first
#define y second

const int N = 1e5 + 10;

struct node { LL mxs, mncs, mnscs, rs, d; }T[N << 2];

#define o T[x]
#define mid ((l + r) >> 1)
#define lc (x << 1)
#define rc (lc | 1)
#define lcq lc, l, mid
#define rcq rc, mid + 1, r
void push(int x, int l, int r) {
	if (o.d) {
		o.mxs += o.d, o.mnscs += o.d, o.rs += o.d;
		if (l < r) T[lc].d += o.d, T[rc].d += o.d;
		o.d = 0;
	}
}

LL cal(int x, int l, int r, LL y) {
	push(x, l, r);
	if (l == r || y >= o.mxs) return y + o.mncs;
	push(lcq), push(rcq);
	if (y <= T[lc].mxs) return max(cal(lcq, y), o.rs);
	else return max(cal(lcq, y), cal(rcq, y));
}

void upd(int x, int l, int r) {
	o.mxs = max(T[lc].mxs, T[rc].mxs);
	o.mncs = min(T[lc].mncs, T[rc].mncs);
	o.mnscs = min(T[lc].mnscs, o.rs = cal(rcq, T[lc].mxs));
}

int a, b, c;
int d[N];
void add(int x, int l, int r) {
/*
	if (x == 1) {
		rep(i,a,b) d[i] += c;
		return;
	}*/

	if (a <= l && r <= b) o.d += c, push(x, l, r);
	else {
		push(x, l, r);
		if (a <= mid) add(lcq); else push(lcq);
		if (b >  mid) add(rcq); else push(rcq);
		upd(x, l, r);
	}
}

const LL inf = 1LL << 60;

int n, k, w[N], g[N];
LL sum[N], suf[N], val[N];
void build(int x, int l, int r) {
	if (l == r) o.mxs = suf[l], o.mncs = -suf[l], o.mnscs = inf;
	else build(lcq), build(rcq), upd(x, l, r);
}

vector<int> son[N];
int nxt[N];

void init() {
	rep(i,1,n - 1) sum[i] = sum[i - 1] + g[i] - w[i];
	static int st[N]; int top = 0;
	fill(nxt + 1, nxt + n + 1, n);
	rep(i,1,n - 1) {
		while (top && sum[st[top]] > sum[i]) nxt[st[top--]] = i;
		st[++top] = i;
	}
	rep(i,1,n) suf[i] = suf[i - 1] - w[i - 1] + g[i];
	rep(i,1,n) val[i] = (nxt[i] < n) ? sum[i] - sum[nxt[i]] : 0;
	rep(i,1,n - 1) son[nxt[i]].pb(i);
}

int ans = 1;

LL mx(int x, int l, int r) {
	push(x, l, r);
	if (a <= l && r <= b) return o.mxs;
	else return max((a <= mid ? mx(lcq) : -inf), (b > mid ? mx(rcq) : -inf));
}

int qry(int x, int l, int r, LL y) {
/*
	if (x == 1) {
		dep(i,b,a) {
			LL mx = -inf;
			rep(j,a,i - 1) mx = max(mx, 1LL * suf[j] + d[j]);
			if (mx - suf[i] <= k) return i;
		}
		return 0;
	}*/

	push(x, l, r);
   	if (a <= l && r <= b) {
		if (l == r) return (y + o.mncs <= k) ? l : 0;
		else {
			push(lcq), push(rcq);
			if (cal(rcq, max(y, T[lc].mxs)) <= k) return qry(rcq, max(y, T[lc].mxs));
			else return qry(lcq, y);
		}
	} else {
		if (b > mid) { int t = qry(rcq, max((a <= mid ? mx(lcq) : -inf), y)); if (t) return t; }
		if (a <= mid) return qry(lcq, y);
		return 0;
	}
}

void dfs(int x) {
	if (nxt[x] < n) a = nxt[x], b = n, c = val[x], add(1, 1, n);

	if (x < n) {
		a = x + 1, b = n; int t = qry(1, 1, n, -inf);
		if (t) ans = max(ans, t - x);
	}

	int len = son[x].size(); Rep(i,len) dfs(son[x][i]);

	if (nxt[x] < n) a = nxt[x], b = n, c = -val[x], add(1, 1, n);
}
int main() {
	scanf("%d%d",&n,&k);
	rep(i,1,n - 1) scanf("%d",w + i);
	rep(i,1,n) scanf("%d",g + i);
	n++;
	dep(i,n,2) g[i] = g[i - 1];
	dep(i,n-1,2) w[i] = w[i - 1];
	g[1] = 0, w[1] = k + 1;

	init(), build(1, 1, n);
	dfs(n);
	printf("%d\n",ans);
	return 0;
}


#include <iostream>
#include <cstdio>
#include <map>
#include <set>
#include <queue>
#include <vector>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#define rep(i,a,b) for(int i = a; i <= b; i++)
#define dep(i,a,b) for(int i = a; i >= b; i--)
#define Rep(i,a) for(int i = 0; i < a; i++)
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define ab(x) ((x) < 0 ? -(x) : (x))
using namespace std;
typedef long long LL;
typedef map<int, int>::iterator mit;
typedef set<int>::iterator sit;
typedef pair<int, int> pii;
#define x first
#define y second

const int N = 1e5 + 10;

struct node { LL mxs, mncs, mnscs, rs, d; }T[N << 2];

#define o T[x]
#define mid ((l + r) >> 1)
#define lc (x << 1)
#define rc (lc | 1)
#define lcq lc, l, mid
#define rcq rc, mid + 1, r
void push(int x, int l, int r) {
	if (o.d) {
		o.mxs += o.d, o.mnscs += o.d, o.rs += o.d;
		if (l < r) T[lc].d += o.d, T[rc].d += o.d;
		o.d = 0;
	}
}

LL cal(int x, int l, int r, LL y) {
	push(x, l, r);
	if (l == r || y >= o.mxs) return y + o.mncs;
	push(lcq);
	if (y <= T[lc].mxs) return max(cal(lcq, y), o.rs);
	else return max(cal(lcq, y), cal(rcq, y));
}

void upd(int x, int l, int r) {
	o.mxs = max(T[lc].mxs, T[rc].mxs);
	o.mncs = min(T[lc].mncs, T[rc].mncs);
	o.mnscs = min(T[lc].mnscs, o.rs = cal(rcq, T[lc].mxs));
}

int a, b, c;
int d[N];
void add(int x, int l, int r) {
	if (x == 1) {
		rep(i,a,b) d[i] += c;
		return;
	}

	if (a <= l && r <= b) o.d += c, push(x, l, r);
	else {
		push(x, l, r);
		if (a <= mid) add(lcq); else push(lcq);
		if (b >  mid) add(rcq); else push(rcq);
		upd(x, l, r);
	}
}

const LL inf = 1LL << 60;

int n, k, w[N], g[N], sum[N], suf[N], val[N];
void build(int x, int l, int r) {
	if (l == r) o.mxs = suf[l], o.mncs = -suf[l], o.mnscs = inf;
	else build(lcq), build(rcq), upd(x, l, r);
}

vector<int> son[N];
int nxt[N];
void init() {
	rep(i,1,n - 1) sum[i] = sum[i - 1] + g[i] - w[i];
	static int st[N]; int top = 0;
	fill(nxt + 1, nxt + n + 1, n);
	rep(i,1,n) {
		while (top && sum[st[top]] > sum[i]) nxt[st[top--]] = i;
		st[++top] = i;
	}
	rep(i,1,n) suf[i] = suf[i - 1] - w[i - 1] + g[i];
	rep(i,1,n) val[i] = (nxt[i] < n) ? sum[i] - sum[nxt[i]] : 0;
	rep(i,1,n - 1) son[nxt[i]].pb(i);
}

int ans = 1;

LL mx(int x, int l, int r) {
	push(x, l, r);
	if (a <= l && r <= b) return o.mxs;
	else return max((a <= mid ? mx(lcq) : -inf), (b > mid ? mx(rcq) : -inf));
}

int qry(int x, int l, int r, LL y) {
	if (x == 1) {
		dep(i,b,a) {
			LL mx = -inf;
			rep(j,a,i - 1) mx = max(mx, 1LL * suf[j] + d[j]);
			if (mx - suf[i] <= k) return i;
		}
		return 0;
	}
	push(x, l, r);
   	if (a <= l && r <= b) {
		if (l == r) return (y + o.mncs <= k) ? l : 0;
		else {
			push(lcq), push(rcq);
			if (cal(rcq, max(y, T[lc].mxs)) <= k) return qry(rcq, max(y, T[lc].mxs));
			else return qry(lcq, y);
		}
	} else {
		if (b > mid) { int t = qry(rcq, max((a <= mid ? mx(lcq) : -inf), y)); if (t) return t; }
		if (a <= mid) return qry(lcq, y);
		return 0;
	}
}

void dfs(int x) {
	if (nxt[x] < n) a = nxt[x], b = n, c = val[x], add(1, 1, n);

	if (g[x] - w[x] < 0) a = x, b = n, c = w[x] - g[x], add(1, 1, n);
	if (x < n) {
		a = x, b = n; int t = qry(1, 1, n, -inf);
		if (t) ans = max(ans, t - x + 1);
	}
	if (g[x] - w[x] < 0) a = x, b = n, c = g[x] - w[x], add(1, 1, n);

	int len = son[x].size(); Rep(i,len) dfs(son[x][i]);

	if (nxt[x] < n) a = nxt[x], b = n, c = -val[x], add(1, 1, n);
	add(1, 1, n);
}
int main() {
	scanf("%d%d",&n,&k);
	rep(i,1,n - 1) scanf("%d",w + i);
	rep(i,1,n) scanf("%d",g + i);
	init(), build(1, 1, n);
	dfs(n);
	printf("%d\n",ans);
	return 0;
}


/*
	令s_i = \sum -g_j + w_j - g_i
	那么最后的答案就是max(s_i | l <= s_i <= r) - s_r + c_r <= k
	每次给区间加x

	我们二分一个j之后，每次维护的就是一个后缀[j..n]的min( max(s_i) - s_r + c_r )
	先考虑对区间维护这个东西，这个信息本身并不区间可加
	但是你注意max(s_i)生效的是一个前缀和区间，我们可以二分出这个区间，就像区间上升序列线段树一样合并

	然后我们二分j的时候必须线段树上二分来保证复杂度

	线段树上要维护 1.max(si) 2.c_i - s_i的最小值 3.max(s_i) + c_r - s_r的最小值 4.右儿子对3的贡献

	标记是区间+d, 它对1影响是+d, 对2没有影响，对3影响是+d，对4影响也是+d

	然后需要注意我们算的是从走过i这条边之后开始下一次卡住的位置

	所以如果i自己出发就被卡住，算答案之前要算一下自己的g加的多少
*/

#include <iostream>
#include <cstdio>
#include <map>
#include <set>
#include <queue>
#include <vector>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#define rep(i,a,b) for(int i = a; i <= b; i++)
#define dep(i,a,b) for(int i = a; i >= b; i--)
#define Rep(i,a) for(int i = 0; i < a; i++)
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define ab(x) ((x) < 0 ? -(x) : (x))
using namespace std;
typedef long long LL;
typedef map<int, int>::iterator mit;
typedef set<int>::iterator sit;
typedef pair<int, int> pii;
#define x first
#define y second

const int N = 1e5 + 10;

struct node { LL mxs, mncs, mnscs, rs, d; }T[N << 2];

#define o T[x]
#define mid ((l + r) >> 1)
#define lc (x << 1)
#define rc (lc | 1)
#define lcq lc, l, mid
#define rcq rc, mid + 1, r
void push(int x, int l, int r) {
	if (o.d) {
		o.mxs += o.d, o.mnscs += o.d, o.rs += o.d;
		if (l < r) T[lc].d += o.d, T[rc].d += o.d;
		o.d = 0;
	}
}

LL cal(int x, int l, int r, LL y) {
	push(x, l, r);
	if (l == r || y >= o.mxs) return y + o.mncs;
	push(lcq);
	if (y <= T[lc].mxs) return max(cal(lcq, y), o.rs);
	else return max(cal(lcq, y), cal(rcq, y));
}

void upd(int x, int l, int r) {
	o.mxs = max(T[lc].mxs, T[rc].mxs);
	o.mncs = min(T[lc].mncs, T[rc].mncs);
	o.mnscs = min(T[lc].mnscs, o.rs = cal(rcq, T[lc].mxs));
}

int a, b, c;
int d[N];
void add(int x, int l, int r) {
/*
	if (x == 1) {
		rep(i,a,b) d[i] += c;
		return;
	}*/

	if (a <= l && r <= b) o.d += c, push(x, l, r);
	else {
		push(x, l, r);
		if (a <= mid) add(lcq); else push(lcq);
		if (b >  mid) add(rcq); else push(rcq);
		upd(x, l, r);
	}
}

const LL inf = 1LL << 60;

int n, k, w[N], g[N], sum[N], suf[N], val[N];
void build(int x, int l, int r) {
	if (l == r) o.mxs = suf[l], o.mncs = -suf[l], o.mnscs = inf;
	else build(lcq), build(rcq), upd(x, l, r);
}

vector<int> son[N];
int nxt[N];
void init() {
	rep(i,1,n - 1) sum[i] = sum[i - 1] + g[i] - w[i];
	static int st[N]; int top = 0;
	fill(nxt + 1, nxt + n + 1, n);
	rep(i,1,n - 1) {
		while (top && sum[st[top]] > sum[i]) nxt[st[top--]] = i;
		st[++top] = i;
	}
	rep(i,1,n) suf[i] = suf[i - 1] - w[i - 1] + g[i];
	rep(i,1,n) val[i] = (nxt[i] < n) ? sum[i] - sum[nxt[i]] : 0;
	rep(i,1,n - 1) son[nxt[i]].pb(i);
}

int ans = 1;

LL mx(int x, int l, int r) {
	push(x, l, r);
	if (a <= l && r <= b) return o.mxs;
	else return max((a <= mid ? mx(lcq) : -inf), (b > mid ? mx(rcq) : -inf));
}

int qry(int x, int l, int r, LL y) {
/*
	if (x == 1) {
		dep(i,b,a) {
			LL mx = -inf;
			rep(j,a,i - 1) mx = max(mx, 1LL * suf[j] + d[j]);
			if (mx - suf[i] <= k) return i;
		}
		return 0;
	}*/

	push(x, l, r);
   	if (a <= l && r <= b) {
		if (l == r) return (y + o.mncs <= k) ? l : 0;
		else {
			push(lcq), push(rcq);
			if (cal(rcq, max(y, T[lc].mxs)) <= k) return qry(rcq, max(y, T[lc].mxs));
			else return qry(lcq, y);
		}
	} else {
		if (b > mid) { int t = qry(rcq, max((a <= mid ? mx(lcq) : -inf), y)); if (t) return t; }
		if (a <= mid) return qry(lcq, y);
		return 0;
	}
}

void dfs(int x) {
	if (nxt[x] < n) a = nxt[x], b = n, c = val[x], add(1, 1, n);

	if (x < n) {
		a = x + 1, b = n; int t = qry(1, 1, n, -inf);
		if (t) ans = max(ans, t - x);
	}

	int len = son[x].size(); Rep(i,len) dfs(son[x][i]);

	if (nxt[x] < n) a = nxt[x], b = n, c = -val[x], add(1, 1, n);
}
int main() {
	scanf("%d%d",&n,&k);
	rep(i,1,n - 1) scanf("%d",w + i);
	rep(i,1,n) scanf("%d",g + i);
	n++;
	dep(i,n,2) g[i] = g[i - 1];
	dep(i,n-1,2) w[i] = w[i - 1];
	g[1] = 0, w[1] = k + 1;

	init(), build(1, 1, n);
	dfs(n);
	printf("%d\n",ans);
	return 0;
}


/*
	令s_i = \sum -g_j + w_j - g_i
	那么最后的答案就是max(s_i | l <= s_i <= r) - s_r + c_r <= k
	每次给区间加x

	我们二分一个j之后，每次维护的就是一个后缀[j..n]的min( max(s_i) - s_r + c_r )
	先考虑对区间维护这个东西，这个信息本身并不区间可加
	但是你注意max(s_i)生效的是一个前缀和区间，我们可以二分出这个区间，就像区间上升序列线段树一样合并

	然后我们二分j的时候必须线段树上二分来保证复杂度

	线段树上要维护 1.max(si) 2.c_i - s_i的最小值 3.max(s_i) + c_r - s_r的最小值 4.右儿子对3的贡献

	标记是区间+d, 它对1影响是+d, 对2没有影响，对3影响是+d，对4影响也是+d

	然后需要注意我们算的是从走过i这条边之后开始下一次卡住的位置

	所以如果i自己出发就被卡住，算答案之前要算一下自己的g加的多少
*/

#include <iostream>
#include <cstdio>
#include <map>
#include <set>
#include <queue>
#include <vector>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#define rep(i,a,b) for(int i = a; i <= b; i++)
#define dep(i,a,b) for(int i = a; i >= b; i--)
#define Rep(i,a) for(int i = 0; i < a; i++)
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define ab(x) ((x) < 0 ? -(x) : (x))
using namespace std;
typedef long long LL;
typedef map<int, int>::iterator mit;
typedef set<int>::iterator sit;
typedef pair<int, int> pii;
#define x first
#define y second

const int N = 1e5 + 10;

struct node { LL mxs, mncs, mnscs, rs, d; }T[N << 2];

#define o T[x]
#define mid ((l + r) >> 1)
#define lc (x << 1)
#define rc (lc | 1)
#define lcq lc, l, mid
#define rcq rc, mid + 1, r
void push(int x, int l, int r) {
	if (o.d) {
		o.mxs += o.d, o.mnscs += o.d, o.rs += o.d;
		if (l < r) T[lc].d += o.d, T[rc].d += o.d;
		o.d = 0;
	}
}

LL cal(int x, int l, int r, LL y) {
	push(x, l, r);
	if (l == r || y >= o.mxs) return y + o.mncs;
	push(lcq), push(rcq);
	if (y <= T[lc].mxs) return max(cal(lcq, y), o.rs);
	else return max(cal(lcq, y), cal(rcq, y));
}

void upd(int x, int l, int r) {
	o.mxs = max(T[lc].mxs, T[rc].mxs);
	o.mncs = min(T[lc].mncs, T[rc].mncs);
	o.mnscs = min(T[lc].mnscs, o.rs = cal(rcq, T[lc].mxs));
}

int a, b; LL c;
int d[N];
void add(int x, int l, int r) {
/*
	if (x == 1) {
		rep(i,a,b) d[i] += c;
		return;
	}*/

	if (a <= l && r <= b) o.d += c, push(x, l, r);
	else {
		push(x, l, r);
		if (a <= mid) add(lcq); else push(lcq);
		if (b >  mid) add(rcq); else push(rcq);
		upd(x, l, r);
	}
}

const LL inf = 1LL << 60;

int n, k, w[N], g[N];
LL sum[N], suf[N], val[N];
void build(int x, int l, int r) {
	if (l == r) o.mxs = suf[l], o.mncs = -suf[l], o.mnscs = inf;
	else build(lcq), build(rcq), upd(x, l, r);
}

vector<int> son[N];
int nxt[N];

void init() {
	rep(i,1,n - 1) sum[i] = sum[i - 1] + g[i] - w[i];
	static int st[N]; int top = 0;
	fill(nxt + 1, nxt + n + 1, n);
	rep(i,1,n - 1) {
		while (top && sum[st[top]] > sum[i]) nxt[st[top--]] = i;
		st[++top] = i;
	}
	rep(i,1,n) suf[i] = suf[i - 1] - w[i - 1] + g[i];
	rep(i,1,n) val[i] = (nxt[i] < n) ? sum[i] - sum[nxt[i]] : 0;
	rep(i,1,n - 1) son[nxt[i]].pb(i);
}

int ans = 1;

LL mx(int x, int l, int r) {
	push(x, l, r);
	if (a <= l && r <= b) return o.mxs;
	else return max((a <= mid ? mx(lcq) : -inf), (b > mid ? mx(rcq) : -inf));
}

int qry(int x, int l, int r, LL y) {
/*
	if (x == 1) {
		dep(i,b,a) {
			LL mx = -inf;
			rep(j,a,i - 1) mx = max(mx, 1LL * suf[j] + d[j]);
			if (mx - suf[i] <= k) return i;
		}
		return 0;
	}*/

	push(x, l, r);
   	if (a <= l && r <= b) {
		if (l == r) return (y + o.mncs <= k) ? l : 0;
		else {
			push(lcq), push(rcq);
			if (cal(rcq, max(y, T[lc].mxs)) <= k) return qry(rcq, max(y, T[lc].mxs));
			else return qry(lcq, y);
		}
	} else {
		if (b > mid) { int t = qry(rcq, max((a <= mid ? mx(lcq) : -inf), y)); if (t) return t; }
		if (a <= mid) return qry(lcq, y);
		return 0;
	}
}

void dfs(int x) {
	if (nxt[x] < n) a = nxt[x], b = n, c = val[x], add(1, 1, n);

	if (x < n) {
		a = x + 1, b = n; int t = qry(1, 1, n, -inf);
		if (t) ans = max(ans, t - x);
	}

	int len = son[x].size(); Rep(i,len) dfs(son[x][i]);

	if (nxt[x] < n) a = nxt[x], b = n, c = -val[x], add(1, 1, n);
}
int main() {
	scanf("%d%d",&n,&k);
	rep(i,1,n - 1) scanf("%d",w + i);
	rep(i,1,n) scanf("%d",g + i);
	n++;
	dep(i,n,2) g[i] = g[i - 1];
	dep(i,n-1,2) w[i] = w[i - 1];
	g[1] = 0, w[1] = k + 1;

	init(), build(1, 1, n);
	dfs(n);
	printf("%d\n",ans);
	return 0;
}


#include <iostream>
#include <cstdio>
#include <map>
#include <set>
#include <queue>
#include <vector>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#define rep(i,a,b) for(int i = a; i <= b; i++)
#define dep(i,a,b) for(int i = a; i >= b; i--)
#define Rep(i,a) for(int i = 0; i < a; i++)
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define ab(x) ((x) < 0 ? -(x) : (x))
using namespace std;
typedef long long LL;
typedef map<int, int>::iterator mit;
typedef set<int>::iterator sit;
typedef pair<int, int> pii;
#define x first
#define y second
const LL inf = 1LL << 60;
const int N = 1e5 + 10;
#define mid ((l + r) >> 1)
int n, k, w[N], g[N];

LL Sw[N], Sg[N];
LL s1[N], s2[N];
struct sta{ LL mx[3]; } T[N << 2];
sta operator + (const sta &a, const sta &b) {
	sta c;
	Rep(d,3) c.mx[d] = max(a.mx[d], b.mx[d]);
	c.mx[2] = max(c.mx[2], a.mx[0] + b.mx[1]);
	return c;
}
namespace seg {
	#define lc (x << 1)
	#define rc (lc | 1)
	#define mid ((l + r) >> 1)
	#define lcq lc, l, mid
	#define rcq rc, mid + 1, r
	void build(int x, int l, int r) {
		if (l == r) T[x] = (sta){s1[l], s2[l], s1[l] + s2[l]};
		else build(lcq), build(rcq), T[x] = T[lc] + T[rc];
	}
	int a, b;
	sta qry(int x, int l, int r) {
		if (a <= l && r <= b) return T[x];
		else {
			sta t = (sta){-inf, -inf, -inf};
			if (a <= mid) t = t + qry(lcq);
			if (b >  mid) t = t + qry(rcq);
			return t;
		}
	}
}

bool check(int L) {
	rep(i,1,n - 1) Sw[i] = Sw[i - 1] + w[i];
	rep(i,1,n) Sg[i] = Sg[i - 1] + g[i];

	rep(i,1,n - 1) s1[i] = s1[i - 1] + g[i] - w[i];
	LL s = 0; rep(i,1,n) s -= g[i], s2[i] = s, s += w[i];

	rep(i,1,n) s1[i] = -s1[i], s2[i] = -s2[i];

	seg::build(1, 1, n);

	rep(i,1,n - L + 1) {
		seg::a = i, seg::b = i + L - 2;
		sta t = seg::qry(1, 1, n);
		LL mnW = max(t.mx[2], t.mx[0] + s2[i + L - 1]);
		LL sum = k - (Sw[i + L - 2] - Sw[i - 1]) + (Sg[i + L - 1] - Sg[i - 1]);
		if (sum >= mnW) return true;
	}
	return false;
}

int main() {
	scanf("%d%d",&n,&k);
	rep(i,1,n - 1) scanf("%d",w + i);
	rep(i,1,n) scanf("%d",g + i);
	int l = 1, r = n + 1;
	while (l + 1 < r) if (check(mid)) l = mid; else r = mid;
	printf("%d\n",l);
	return 0;
}


#include <iostream>
#include <cstdio>
#include <map>
#include <set>
#include <queue>
#include <vector>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#define rep(i,a,b) for(int i = a; i <= b; i++)
#define dep(i,a,b) for(int i = a; i >= b; i--)
#define Rep(i,a) for(int i = 0; i < a; i++)
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define ab(x) ((x) < 0 ? -(x) : (x))
using namespace std;
typedef long long LL;
typedef map<int, int>::iterator mit;
typedef set<int>::iterator sit;
typedef pair<int, int> pii;
#define x first
#define y second
const int N = 1e5 + 10;
#define mid ((l + r) >> 1)
int n, k, w[N], g[N];

bool check(int L) {
	rep(i,1,n - L + 1) {
		LL t1 = 0, t2 = 0, mnW = 0, s = 0;
		Rep(j,L) {
			if (j < L - 1) {
				s = s + g[i + j] - w[i + j];
				t1 = min(t1, s);
			}
			t2 -= g[i + j];
			mnW = max(mnW, -t2 - t1);
			t2 += w[i + j];
		}
		LL sum = k;
		Rep(j,L) { if (j < L - 1) sum -= w[i + j]; sum += g[i + j]; }
		if (sum >= mnW) return true;
	}
	return false;
}

int main() {
	scanf("%d%d",&n,&k);
	rep(i,1,n - 1) scanf("%d",w + i);
	rep(i,1,n) scanf("%d",g + i);
	int l = 1, r = n + 1;
	while (l + 1 < r) if (check(mid)) l = mid; else r = mid;
	printf("%d\n",l);
	return 0;
}


#include <iostream>
#include <cstdio>
#include <map>
#include <set>
#include <queue>
#include <vector>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#define rep(i,a,b) for(int i = a; i <= b; i++)
#define dep(i,a,b) for(int i = a; i >= b; i--)
#define Rep(i,a) for(int i = 0; i < a; i++)
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define ab(x) ((x) < 0 ? -(x) : (x))
using namespace std;
typedef long long LL;
typedef map<int, int>::iterator mit;
typedef set<int>::iterator sit;
typedef pair<int, int> pii;
#define x first
#define y second
const LL inf = 1LL << 60;
const int N = 1e5 + 10;
#define mid ((l + r) >> 1)
int n, k, w[N], g[N];

LL Sw[N], Sg[N];
LL s1[N], s2[N];
struct sta{ LL mx[3]; } T[N << 2];
sta operator + (const sta &a, const sta &b) {
	sta c;
	Rep(d,3) c.mx[d] = max(a.mx[d], b.mx[d]);
	c.mx[2] = max(c.mx[2], a.mx[0] + b.mx[1]);
	return c;
}
namespace seg {
	#define lc (x << 1)
	#define rc (lc | 1)
	#define mid ((l + r) >> 1)
	#define lcq lc, l, mid
	#define rcq rc, mid + 1, r
	void build(int x, int l, int r) {
		if (l == r) T[x] = (sta){s1[l], s2[l], s1[l] + s2[l]};
		else build(lcq), build(rcq), T[x] = T[lc] + T[rc];
	}
	int a, b;
	sta qry(int x, int l, int r) {
		if (a <= l && r <= b) return T[x];
		else {
			sta t = (sta){-inf, -inf, -inf};
			if (a <= mid) t = t + qry(lcq);
			if (b >  mid) t = t + qry(rcq);
			return t;
		}
	}
}

bool check(int L) {
	rep(i,1,n - 1) Sw[i] = Sw[i - 1] + w[i];
	rep(i,1,n) Sg[i] = Sg[i - 1] + g[i];

	LL s = 0; rep(i,1,n) s -= g[i], s2[i] = s, s += w[i];
	rep(i,1,n - 1) s1[i] = s1[i - 1] + g[i] - w[i];

	rep(i,1,n) s1[i] = -s1[i], s2[i] = -s2[i];

	seg::build(1, 1, n);

	rep(i,1,n - L + 1) {
		seg::a = i, seg::b = i + L - 2;
		sta t = seg::qry(1, 1, n);
		LL mnW = t.mx[2];
		mnW = max(mnW, max(t.mx[0], s1[i - 1]) + s2[i + L - 1]);
		mnW = max(mnW, t.mx[1] + s1[i - 1]);
		LL sum = k - (Sw[i + L - 2] - Sw[i - 1]) + (Sg[i + L - 1] - Sg[i - 1]);
		if (sum >= mnW) return true;
	}
	return false;
}

int main() {
	scanf("%d%d",&n,&k);
	rep(i,1,n - 1) scanf("%d",w + i);
	rep(i,1,n) scanf("%d",g + i);
	int l = 1, r = n + 1;
	while (l + 1 < r) if (check(mid)) l = mid; else r = mid;
	printf("%d\n",l);
	return 0;
}


#include <cstdio>
#include <algorithm>

int n,K,ans,w[100010],g[100010],stk[100010],top,f[100010];
const long long inf=1000000000000000000ll;
struct point{
	long long mx1,mx2,totmx;
}se[400001];
long long lazy[400001],S1[100010],S2[100010];
void pushdown(int x,long long val){se[x].mx1+=val,se[x].totmx+=val,lazy[x]+=val;}
void spread(int root,int l,int r){
	if(l==r)return;
	if(lazy[root]){
		pushdown(root<<1,lazy[root]);
		pushdown(root<<1|1,lazy[root]);
		lazy[root]=0;
	}
}
long long getval(int root,int l,int r,long long x){
	spread(root,l,r);
	if(l==r)return se[root].mx2+x;
	if(se[root<<1].mx1<=x)return std::min(x+se[root<<1].mx2,getval(root<<1|1,((l+r)>>1)+1,r,x));
	else return std::min(se[root].totmx,getval(root<<1,l,(l+r)>>1,x));
}
void pushup(int root,int l,int r){
	se[root]=(point){
		std::max(se[root<<1].mx1,se[root<<1|1].mx1),
		std::min(se[root<<1].mx2,se[root<<1|1].mx2),
		getval(root<<1|1,((l+r)>>1)+1,r,se[root<<1].mx1)};
}
void build(int root,int l,int r){
	if(l==r){
		se[root]=(point){S2[l],-S2[l],inf};
		return;
	}
	build(root<<1,l,(l+r)>>1);
	build(root<<1|1,((l+r)>>1)+1,r);
	pushup(root,l,r);
}
void update(int root,int l,int r,int el,int er,long long x){
	if(el>r||er<l)return;
	if(el<=l&&er>=r){
		pushdown(root,x);
		return;
	}
	spread(root,l,r);
	update(root<<1,l,(l+r)>>1,el,er,x);
	update(root<<1|1,((l+r)>>1)+1,r,el,er,x);
	pushup(root,l,r);
}
point merge(point a,int root,int l,int r){
	return (point){
		std::max(a.mx1,se[root].mx1),
		std::min(a.mx2,se[root].mx2),
		std::min(a.totmx,getval(root,l,r,a.mx1))
	};
}
void query(int root,int l,int r,int el,int er,point &x){
	spread(root,l,r);
	if(el>r||er<l)return;
	if(el<=l&&er>=r)return (void)(x=merge(x,root,l,r));
	query(root<<1,l,(l+r)>>1,el,er,x),query(root<<1|1,((l+r)>>1)+1,r,el,er,x);
}
int head[100010],nxt[200010],b[200010],k,fa[100010][21];
void push(int s,int t){
	nxt[++k]=head[s];
	head[s]=k;
	b[k]=t;
}
int getmn(int root,int l,int r,int e,long long x){
	if(se[root].mx1<=x)return n+1;
	if(l==r)return l;
	if(se[root<<1|1].mx1>x)return getmn(root<<1|1,((l+r)>>1)+1,r,e,x);
	else if((l+r)>>1>=e)return getmn(root<<1,l,(l+r)>>1,e,x);
	return n+1;
}
void dfs(int x){
	if(f[x]<=n&&x<=n&&f[x]>2)update(1,1,n,f[x]-1,n,S1[x]-S1[f[x]]);
	long long val=(f[x]==2)?S1[x]-S1[f[x]]:0;
	int tem=x;
	for(int i=20;~i;--i)
		if(S1[x]-S1[fa[tem][i]]<=K)tem=fa[tem][i];
	tem=f[tem]-1;
	for(;;){
		if(x+ans>tem)break;
		point now=(point){-inf,inf,inf},now2=(point){-inf,inf,inf};
		long long fin=inf;
		query(1,1,n,x,x+ans-1,now);
		int l=std::min(getmn(1,1,n,x+ans,now.mx1),tem+1);
		query(1,1,n,x+ans,l-1,now2);
		fin=now.mx1+now2.mx2;
		now2=(point){-inf,inf,inf};
		query(1,1,n,l,tem,now2);
		fin=std::min(fin,now2.totmx);
		if(fin+val<=K)++ans;
		else break;
	}
	for(int i=head[x];i;i=nxt[i])
		dfs(b[i]);
	if(f[x]<=n&&x<=n&&f[x]>2)update(1,1,n,f[x]-1,n,S1[f[x]]-S1[x]);
}
int main(){
	scanf("%d%d",&n,&K);
	for(int i=1;i<n;i++)scanf("%d",w+i);
	for(int i=1;i<=n;i++)scanf("%d",g+i);
	for(int i=2;i<=n;i++)S1[i]=S1[i-1]-w[i-1]+g[i-1];
	for(int i=2;i<=n;i++)S2[i]=S2[i-1]-w[i-1]+g[i];
	stk[0]=n+1;
	S1[n+1]=-inf;
	build(1,1,n);
	for(int i=n;i;i--){
		while(top&&S1[stk[top]]>=S1[i])--top;
		push(stk[top],i);
		f[i]=stk[top];
		stk[++top]=i;
	}
	ans=1;
	for(int i=1;i<=n;i++)fa[i][0]=f[i];
	fa[n+1][0]=n+1;
	for(int j=1;j<=20;j++)
		for(int i=1;i<=n+1;i++)
			fa[i][j]=fa[fa[i][j-1]][j-1];
	dfs(n+1);
	printf("%d\n",ans);
}


#include <cstdio>
#include <algorithm>

int n,K,ans,w[100010],g[100010],stk[100010],top,f[100010];
const long long inf=1000000000000000000ll;
struct point{
	long long mx1,mx2,totmx;
}se[500010];
long long lazy[500010],S1[100010],S2[100010];
void pushdown(int x,long long val){se[x].mx1+=val,se[x].totmx+=val,lazy[x]+=val;}
void spread(int root,int l,int r){
	if(l==r)return;
	if(lazy[root]){
		pushdown(root<<1,lazy[root]);
		pushdown(root<<1|1,lazy[root]);
		lazy[root]=0;
	}
}
long long getval(int root,int l,int r,long long x){
	spread(root,l,r);
	if(l==r)return se[root].mx2+x;
	if(se[root<<1].mx1<=x)return std::min(x+se[root<<1].mx2,getval(root<<1|1,((l+r)>>1)+1,r,x));
	else return std::min(se[root].totmx,getval(root<<1,l,(l+r)>>1,x));
}
void pushup(int root,int l,int r){
	se[root]=(point){
		std::max(se[root<<1].mx1,se[root<<1|1].mx1),
		std::min(se[root<<1].mx2,se[root<<1|1].mx2),
		getval(root<<1|1,((l+r)>>1)+1,r,se[root<<1].mx1)};
}
void build(int root,int l,int r){
	if(l==r){
		se[root]=(point){S2[l],-S2[l],inf};
		return;
	}
	build(root<<1,l,(l+r)>>1);
	build(root<<1|1,((l+r)>>1)+1,r);
	pushup(root,l,r);
}
void update(int root,int l,int r,int el,int er,long long x){
	if(el>r||er<l)return;
	if(el<=l&&er>=r){
		pushdown(root,x);
		return;
	}
	spread(root,l,r);
	update(root<<1,l,(l+r)>>1,el,er,x);
	update(root<<1|1,((l+r)>>1)+1,r,el,er,x);
	pushup(root,l,r);
}
point merge(point a,int root,int l,int r){
	return (point){
		std::max(a.mx1,se[root].mx1),
		std::min(a.mx2,se[root].mx2),
		std::min(a.totmx,getval(root,l,r,a.mx1))
	};
}
void query(int root,int l,int r,int el,int er,point &x){
	spread(root,l,r);
	if(el>r||er<l)return;
	if(el<=l&&er>=r)return (void)(x=merge(x,root,l,r));
	query(root<<1,l,(l+r)>>1,el,er,x);
	query(root<<1|1,((l+r)>>1)+1,r,el,er,x);
}
int head[100010],nxt[200010],b[200010],k,fa[100010][21];
void push(int s,int t){
	nxt[++k]=head[s];
	head[s]=k;
	b[k]=t;
}
int getmn(int root,int l,int r,int e,long long x){
	if(r<e)return n+1;
	spread(root,l,r);
	if(se[root].mx1<=x)return n+1;
	if(l==r)return l;
	int tem=getmn(root<<1,l,(l+r)>>1,e,x);
	if(tem==n+1)return getmn(root<<1|1,((l+r)>>1)+1,r,e,x);
	else return tem;
}
void dfs(int x){
	if(f[x]<=n&&x<=n&&f[x]>2)update(1,1,n,f[x]-1,n,S1[x]-S1[f[x]]);
	long long val=(f[x]==2)?S1[x]-S1[f[x]]:0;
	int tem=x;
	for(int i=20;~i;--i)
		if(S1[x]-S1[fa[tem][i]]<=K)tem=fa[tem][i];
	tem=f[tem]-1;
	for(;;){
		if(x+ans>tem)break;
		point now=(point){-inf,inf,inf},now2=(point){-inf,inf,inf};
		long long fin=inf;
		query(1,1,n,x,x+ans-1,now);
		int l=std::min(getmn(1,1,n,x+ans,now.mx1),tem+1);
		query(1,1,n,x+ans,l-1,now2);
		fin=now.mx1+now2.mx2;
		now2=(point){-inf,inf,inf};
		query(1,1,n,l,tem,now2);
		fin=std::min(fin,now2.totmx);
		if(fin+val<=K)++ans;
		else break;
	}
	for(int i=head[x];i;i=nxt[i])
		dfs(b[i]);
	if(f[x]<=n&&x<=n&&f[x]>2)update(1,1,n,f[x]-1,n,S1[f[x]]-S1[x]);
}
int main(){
	scanf("%d%d",&n,&K);
	for(int i=1;i<n;i++)scanf("%d",w+i);
	for(int i=1;i<=n;i++)scanf("%d",g+i);
	for(int i=2;i<=n;i++)S1[i]=S1[i-1]-w[i-1]+g[i-1];
	for(int i=2;i<=n;i++)S2[i]=S2[i-1]-w[i-1]+g[i];
	stk[0]=n+1;
	S1[n+1]=-inf;
	build(1,1,n);
	for(int i=n;i;i--){
		while(top&&S1[stk[top]]>=S1[i])--top;
		push(stk[top],i);
		f[i]=stk[top];
		stk[++top]=i;
	}
	ans=1;
	for(int i=1;i<=n;i++)fa[i][0]=f[i];
	fa[n+1][0]=n+1;
	for(int j=1;j<=20;j++)
		for(int i=1;i<=n+1;i++)
			fa[i][j]=fa[fa[i][j-1]][j-1];
	dfs(n+1);
	printf("%d\n",ans);
}


#include <cstdio>
#include <algorithm>

int n,K,ans,w[100010],g[100010],stk[100010],top,f[100010];
const long long inf=1000000000000000000ll;
struct point{
	long long mx1,mx2,totmx;
}se[500010];
long long lazy[500010],S1[100010],S2[100010];
void pushdown(int x,long long val){se[x].mx1+=val,se[x].totmx+=val,lazy[x]+=val;}
void spread(int root,int l,int r){
	if(l==r)return;
	if(lazy[root]){
		pushdown(root<<1,lazy[root]);
		pushdown(root<<1|1,lazy[root]);
		lazy[root]=0;
	}
}
long long getval(int root,int l,int r,long long x){
	spread(root,l,r);
	if(l==r)return se[root].mx2+x;
	if(se[root<<1].mx1<=x)return std::min(x+se[root<<1].mx2,getval(root<<1|1,((l+r)>>1)+1,r,x));
	else return std::min(se[root].totmx,getval(root<<1,l,(l+r)>>1,x));
}
void pushup(int root,int l,int r){
	se[root]=(point){
		std::max(se[root<<1].mx1,se[root<<1|1].mx1),
		std::min(se[root<<1].mx2,se[root<<1|1].mx2),
		getval(root<<1|1,((l+r)>>1)+1,r,se[root<<1].mx1)};
}
void build(int root,int l,int r){
	if(l==r){
		se[root]=(point){S2[l],-S2[l],inf};
		return;
	}
	build(root<<1,l,(l+r)>>1);
	build(root<<1|1,((l+r)>>1)+1,r);
	pushup(root,l,r);
}
void update(int root,int l,int r,int el,int er,long long x){
	if(el>r||er<l)return;
	if(el<=l&&er>=r){
		pushdown(root,x);
		return;
	}
	spread(root,l,r);
	update(root<<1,l,(l+r)>>1,el,er,x);
	update(root<<1|1,((l+r)>>1)+1,r,el,er,x);
	pushup(root,l,r);
}
point merge(point a,int root,int l,int r){
	return (point){
		std::max(a.mx1,se[root].mx1),
		std::min(a.mx2,se[root].mx2),
		std::min(a.totmx,getval(root,l,r,a.mx1))
	};
}
void query(int root,int l,int r,int el,int er,point &x){
	spread(root,l,r);
	if(el>r||er<l)return;
	if(el<=l&&er>=r)return (void)(x=merge(x,root,l,r));
	query(root<<1,l,(l+r)>>1,el,er,x);
	query(root<<1|1,((l+r)>>1)+1,r,el,er,x);
}
int head[100010],nxt[200010],b[200010],k,fa[100010][21];
void push(int s,int t){
	nxt[++k]=head[s];
	head[s]=k;
	b[k]=t;
}
int getmn(int root,int l,int r,int e,long long x){
	spread(root,l,r);
	if(se[root].mx1<=x)return n+1;
	if(l==r)return l;
	int tem=n+1;
	if((l+r)>>1>=e)tem=getmn(root<<1,l,(l+r)>>1,e,x);
	if(tem==n+1)return getmn(root<<1|1,((l+r)>>1)+1,r,e,x);
	else return tem;
}
void dfs(int x){
	if(f[x]<=n&&x<=n&&f[x]>2)update(1,1,n,f[x]-1,n,S1[x]-S1[f[x]]);
	long long val=(f[x]==2)?S1[x]-S1[f[x]]:0;
	int tem=x;
	for(int i=20;~i;--i)
		if(S1[x]-S1[fa[tem][i]]<=K)tem=fa[tem][i];
	tem=f[tem]-1;
	for(;;){
		if(x+ans>tem)break;
		point now=(point){-inf,inf,inf},now2=(point){-inf,inf,inf};
		long long fin=inf;
		query(1,1,n,x,x+ans-1,now);
		int l=std::min(getmn(1,1,n,x+ans,now.mx1),tem+1);
		query(1,1,n,x+ans,l-1,now2);
		fin=now.mx1+now2.mx2;
		now2=(point){-inf,inf,inf};
		query(1,1,n,l,tem,now2);
		fin=std::min(fin,now2.totmx);
		if(fin+val<=K)++ans;
		else break;
	}
	for(int i=head[x];i;i=nxt[i])
		dfs(b[i]);
	if(f[x]<=n&&x<=n&&f[x]>2)update(1,1,n,f[x]-1,n,S1[f[x]]-S1[x]);
}
int main(){
	scanf("%d%d",&n,&K);
	for(int i=1;i<n;i++)scanf("%d",w+i);
	for(int i=1;i<=n;i++)scanf("%d",g+i);
	for(int i=2;i<=n;i++)S1[i]=S1[i-1]-w[i-1]+g[i-1];
	for(int i=2;i<=n;i++)S2[i]=S2[i-1]-w[i-1]+g[i];
	stk[0]=n+1;
	S1[n+1]=-inf;
	build(1,1,n);
	for(int i=n;i;i--){
		while(top&&S1[stk[top]]>=S1[i])--top;
		push(stk[top],i);
		f[i]=stk[top];
		stk[++top]=i;
	}
	ans=1;
	for(int i=1;i<=n;i++)fa[i][0]=f[i];
	fa[n+1][0]=n+1;
	for(int j=1;j<=20;j++)
		for(int i=1;i<=n+1;i++)
			fa[i][j]=fa[fa[i][j-1]][j-1];
	dfs(n+1);
	printf("%d\n",ans);
}


#include <cstdio>
#include <algorithm>

int n,K,ans,w[100010],g[100010],stk[100010],top,f[100010];
const long long inf=1000000000000000000ll;
struct point{
	long long mx1,mx2,totmx;
}se[500010];
long long lazy[500010],S1[100010],S2[100010];
void pushdown(int x,long long val){se[x].mx1+=val,se[x].totmx+=val,lazy[x]+=val;}
void spread(int root,int l,int r){
	if(l==r)return;
	if(lazy[root]){
		pushdown(root<<1,lazy[root]);
		pushdown(root<<1|1,lazy[root]);
		lazy[root]=0;
	}
}
long long getval(int root,int l,int r,long long x){
	spread(root,l,r);
	if(l==r)return se[root].mx2+x;
	if(se[root<<1].mx1<=x)return std::min(x+se[root<<1].mx2,getval(root<<1|1,((l+r)>>1)+1,r,x));
	else return std::min(se[root].totmx,getval(root<<1,l,(l+r)>>1,x));
}
void pushup(int root,int l,int r){
	se[root]=(point){
		std::max(se[root<<1].mx1,se[root<<1|1].mx1),
		std::min(se[root<<1].mx2,se[root<<1|1].mx2),
		getval(root<<1|1,((l+r)>>1)+1,r,se[root<<1].mx1)};
}
void build(int root,int l,int r){
	if(l==r){
		se[root]=(point){S2[l],-S2[l],inf};
		return;
	}
	build(root<<1,l,(l+r)>>1);
	build(root<<1|1,((l+r)>>1)+1,r);
	pushup(root,l,r);
}
void update(int root,int l,int r,int el,int er,long long x){
	if(el>r||er<l)return;
	if(el<=l&&er>=r){
		pushdown(root,x);
		return;
	}
	spread(root,l,r);
	update(root<<1,l,(l+r)>>1,el,er,x);
	update(root<<1|1,((l+r)>>1)+1,r,el,er,x);
	pushup(root,l,r);
}
point merge(point a,int root,int l,int r){
	return (point){
		std::max(a.mx1,se[root].mx1),
		std::min(a.mx2,se[root].mx2),
		std::min(a.totmx,getval(root,l,r,a.mx1))
	};
}
void query(int root,int l,int r,int el,int er,point &x){
	spread(root,l,r);
	if(el>r||er<l)return;
	if(el<=l&&er>=r)return (void)(x=merge(x,root,l,r));
	query(root<<1,l,(l+r)>>1,el,er,x);
	query(root<<1|1,((l+r)>>1)+1,r,el,er,x);
}
int head[100010],nxt[200010],b[200010],k,fa[100010][21];
void push(int s,int t){
	nxt[++k]=head[s];
	head[s]=k;
	b[k]=t;
}
int getmn(int root,int l,int r,int e,long long x){
	if(r<e)return n+1;
	spread(root,l,r);
	if(se[root].mx1<=x)return n+1;
	if(l==r)return l;
	int tem=getmn(root<<1,l,(l+r)>>1,e,x);
	if(tem==n+1)return getmn(root<<1|1,((l+r)>>1)+1,r,e,x);
	else return tem;
}
void dfs(int x){
	if(f[x]<=n&&x<=n&&f[x]>2)update(1,1,n,f[x]-1,n,S1[x]-S1[f[x]]);
	long long val=(f[x]==2)?S1[x]-S1[f[x]]:0;
	int tem=x;
	for(int i=20;~i;--i)
		if(S1[x]-S1[fa[tem][i]]<=K)tem=fa[tem][i];
	tem=f[tem]-1;
	for(;;){
		if(x+ans>tem)break;
		point now=(point){-inf,inf,inf},now2=(point){-inf,inf,inf};
		query(1,1,n,x,x+ans-1,now);
		now.totmx=inf;
		query(1,1,n,x+ans,tem,now);
		if(now.totmx+val<=K)++ans;
		else break;
	}
	for(int i=head[x];i;i=nxt[i])
		dfs(b[i]);
	if(f[x]<=n&&x<=n&&f[x]>2)update(1,1,n,f[x]-1,n,S1[f[x]]-S1[x]);
}
int main(){
	scanf("%d%d",&n,&K);
	for(int i=1;i<n;i++)scanf("%d",w+i);
	for(int i=1;i<=n;i++)scanf("%d",g+i);
	for(int i=2;i<=n;i++)S1[i]=S1[i-1]-w[i-1]+g[i-1];
	for(int i=2;i<=n;i++)S2[i]=S2[i-1]-w[i-1]+g[i];
	stk[0]=n+1;
	S1[n+1]=-inf;
	build(1,1,n);
	for(int i=n;i;i--){
		while(top&&S1[stk[top]]>=S1[i])--top;
		push(stk[top],i);
		f[i]=stk[top];
		stk[++top]=i;
	}
	ans=1;
	for(int i=1;i<=n;i++)fa[i][0]=f[i];
	fa[n+1][0]=n+1;
	for(int j=1;j<=20;j++)
		for(int i=1;i<=n+1;i++)
			fa[i][j]=fa[fa[i][j-1]][j-1];
	dfs(n+1);
	printf("%d\n",ans);
}


#include <cstdio>
#include <algorithm>

int n,K,ans,w[100010],g[100010],stk[100010],top,f[100010];
const long long inf=1000000000000000000ll;
struct point{
	long long mx1,mx2,totmx;
}se[400001];
long long lazy[400001],S1[100010],S2[100010];
void pushdown(int x,long long val){se[x].mx1+=val,se[x].totmx+=val,lazy[x]+=val;}
void spread(int root,int l,int r){
	if(l==r)return;
	if(lazy[root]){
		pushdown(root<<1,lazy[root]);
		pushdown(root<<1|1,lazy[root]);
		lazy[root]=0;
	}
}
long long getval(int root,int l,int r,long long x){
	spread(root,l,r);
	if(l==r)return se[root].mx2+x;
	if(se[root<<1].mx1<=x)return std::min(x+se[root<<1].mx2,getval(root<<1|1,((l+r)>>1)+1,r,x));
	else return std::min(se[root].totmx,getval(root<<1,l,(l+r)>>1,x));
}
void pushup(int root,int l,int r){
	se[root]=(point){
		std::max(se[root<<1].mx1,se[root<<1|1].mx1),
		std::min(se[root<<1].mx2,se[root<<1|1].mx2),
		getval(root<<1|1,((l+r)>>1)+1,r,se[root<<1].mx1)};
}
void build(int root,int l,int r){
	if(l==r){
		se[root]=(point){S2[l],-S2[l],inf};
		return;
	}
	build(root<<1,l,(l+r)>>1);
	build(root<<1|1,((l+r)>>1)+1,r);
	pushup(root,l,r);
}
void update(int root,int l,int r,int el,int er,long long x){
	if(el>r||er<l)return;
	if(el<=l&&er>=r){
		pushdown(root,x);
		return;
	}
	spread(root,l,r);
	update(root<<1,l,(l+r)>>1,el,er,x);
	update(root<<1|1,((l+r)>>1)+1,r,el,er,x);
	pushup(root,l,r);
}
point merge(point a,int root,int l,int r){
	return (point){
		std::max(a.mx1,se[root].mx1),
		std::min(a.mx2,se[root].mx2),
		std::min(a.totmx,getval(root,l,r,a.mx1))
	};
}
void query(int root,int l,int r,int el,int er,point &x){
	spread(root,l,r);
	if(el>r||er<l)return;
	if(el<=l&&er>=r)return (void)(x=merge(x,root,l,r));
	query(root<<1,l,(l+r)>>1,el,er,x);
	query(root<<1|1,((l+r)>>1)+1,r,el,er,x);
}
int head[100010],nxt[200010],b[200010],k,fa[100010][21];
void push(int s,int t){
	nxt[++k]=head[s];
	head[s]=k;
	b[k]=t;
}
int getmn(int root,int l,int r,int e,long long x){
	spread(root,l,r);
	if(se[root].mx1<=x)return n+1;
	if(l==r)return l;
	if(se[root<<1|1].mx1>x)return getmn(root<<1|1,((l+r)>>1)+1,r,e,x);
	else if((l+r)>>1>=e)return getmn(root<<1,l,(l+r)>>1,e,x);
	return n+1;
}
void dfs(int x){
	if(f[x]<=n&&x<=n&&f[x]>2)update(1,1,n,f[x]-1,n,S1[x]-S1[f[x]]);
	long long val=(f[x]==2)?S1[x]-S1[f[x]]:0;
	int tem=x;
	for(int i=20;~i;--i)
		if(S1[x]-S1[fa[tem][i]]<=K)tem=fa[tem][i];
	tem=f[tem]-1;
	for(;;){
		if(x+ans>tem)break;
		point now=(point){-inf,inf,inf},now2=(point){-inf,inf,inf};
		long long fin=inf;
		query(1,1,n,x,x+ans-1,now);
		int l=std::min(getmn(1,1,n,x+ans,now.mx1),tem+1);
		query(1,1,n,x+ans,l-1,now2);
		fin=now.mx1+now2.mx2;
		now2=(point){-inf,inf,inf};
		query(1,1,n,l,tem,now2);
		fin=std::min(fin,now2.totmx);
		if(fin+val<=K)++ans;
		else break;
	}
	for(int i=head[x];i;i=nxt[i])
		dfs(b[i]);
	if(f[x]<=n&&x<=n&&f[x]>2)update(1,1,n,f[x]-1,n,S1[f[x]]-S1[x]);
}
int main(){
	scanf("%d%d",&n,&K);
	for(int i=1;i<n;i++)scanf("%d",w+i);
	for(int i=1;i<=n;i++)scanf("%d",g+i);
	for(int i=2;i<=n;i++)S1[i]=S1[i-1]-w[i-1]+g[i-1];
	for(int i=2;i<=n;i++)S2[i]=S2[i-1]-w[i-1]+g[i];
	stk[0]=n+1;
	S1[n+1]=-inf;
	build(1,1,n);
	for(int i=n;i;i--){
		while(top&&S1[stk[top]]>=S1[i])--top;
		push(stk[top],i);
		f[i]=stk[top];
		stk[++top]=i;
	}
	ans=1;
	for(int i=1;i<=n;i++)fa[i][0]=f[i];
	fa[n+1][0]=n+1;
	for(int j=1;j<=20;j++)
		for(int i=1;i<=n+1;i++)
			fa[i][j]=fa[fa[i][j-1]][j-1];
	dfs(n+1);
	printf("%d\n",ans);
}


#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define lson x<<1
#define rson x<<1|1
using namespace std;

const int maxn=100010;
typedef long long ll;
int n,K,top,cnt,ans;
int st[maxn],to[maxn],nxt[maxn],head[maxn],nt[maxn];
ll g[maxn],w[maxn],pre[maxn],suf[maxn];
ll mp[maxn<<2],sp[maxn<<2];	//max_p(p=cost-suf),max_(suf{l..j-1}+p)
ll ms[maxn<<2],tag[maxn<<2];	//max_suf
inline void add(int a,int b)
{
	to[cnt]=b,nxt[cnt]=head[a],head[a]=cnt++;
}
inline void upd(int x,ll y)
{
	tag[x]+=y,ms[x]+=y,sp[x]+=y;
}
inline void pushdown(int x)
{
	if(tag[x])
	{
		upd(lson,tag[x]),upd(rson,tag[x]);
		tag[x]=0;
	}
}
ll calc(int l,int r,int x,ll t)
{
	if(l==r)	return t+mp[x];
	pushdown(x);
	int mid=(l+r)>>1;
	if(ms[lson]>=t)	return min(calc(l,mid,lson,t),sp[x]);
	return min(t+mp[lson],calc(mid+1,r,rson,t));
}
inline void pushup(int l,int r,int x)
{
	ms[x]=max(ms[lson],ms[rson]);
	int mid=(l+r)>>1;
	sp[x]=calc(mid+1,r,rson,ms[lson]);
}
void build(int l,int r,int x)
{
	if(l==r)
	{
		ms[x]=suf[l];
		mp[x]=-suf[l];
		return ;
	}
	int mid=(l+r)>>1;
	build(l,mid,lson),build(mid+1,r,rson);
	pushup(l,r,x),mp[x]=min(mp[lson],mp[rson]);
}
void updata(int l,int r,int x,int a,int b,ll t)
{
	if(a>b)	return ;
	if(a<=l&&r<=b)
	{
		upd(x,t);
		return ;
	}
	pushdown(x);
	int mid=(l+r)>>1;
	if(a<=mid)	updata(l,mid,lson,a,b,t);
	if(b>mid)	updata(mid+1,r,rson,a,b,t);
	pushup(l,r,x);
}
int solve(int l,int r,int x,ll t)
{
	if(l==r)	return t+mp[x]<=K?l:0;
	pushdown(x);
	int mid=(l+r)>>1;
	if(t+mp[rson]<=K)	return solve(mid+1,r,rson,t);
	return solve(l,mid,lson,t);
}
int query(int l,int r,int x,ll t)
{
	if(l==r)	return t+mp[x]<=K?l:0;
	pushdown(x);
	int mid=(l+r)>>1;
	if(ms[lson]>=t)
	{
		if(sp[x]<=K)	return query(mid+1,r,rson,ms[lson]);
		else	return query(l,mid,lson,t);
	}
	else
	{
		return max(solve(l,mid,lson,t),query(mid+1,r,rson,t));
	}
}
void init(int l,int r,int x)
{
	if(l==r)	return ;
	pushdown(x);
	int mid=(l+r)>>1;
	init(l,mid,lson),init(mid+1,r,rson);
}
void dfs(int x)
{
	if(x!=n+1)
	{
		updata(1,n,1,1,x-1,-1e17);
		updata(1,n,1,nt[x]-1,n,pre[x-1]-pre[nt[x]-1]);
		ans=max(ans,query(1,n,1,-1e17)-x+1);
		updata(1,n,1,1,x-1,1e17);
	}
	for(int i=head[x];i!=-1;i=nxt[i])	dfs(to[i]);
	if(x!=n+1)
	{
		updata(1,n,1,nt[x]-1,n,-(pre[x-1]-pre[nt[x]-1]));
	}
}
inline int rd()
{
	int ret=0,f=1;	char gc=getchar();
	while(gc<'0'||gc>'9')	{if(gc=='-')	f=-f;	gc=getchar();}
	while(gc>='0'&&gc<='9')	ret=ret*10+(gc^'0'),gc=getchar();
	return ret*f;
}
int main()
{
	memset(head,-1,sizeof(head));
	n=rd(),K=rd();
	int i;
	for(i=1;i<n;i++)	w[i]=rd();
	w[n]=1e17;
	for(i=1;i<=n;i++)	g[i]=rd(),pre[i]=pre[i-1]+g[i]-w[i],suf[i]=suf[i-1]+g[i]-w[i-1];
	for(st[top=0]=n,i=n-1;i>=0;i--)
	{
		while(top&&pre[st[top]]>=pre[i])	top--;
		nt[i+1]=st[top]+1,add(st[top]+1,i+1),st[++top]=i;
	}
	build(1,n,1);
	dfs(n+1);
	printf("%d",ans);
	return 0;
}


#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define lson x<<1
#define rson x<<1|1
using namespace std;

const int maxn=100010;
typedef long long ll;
int n,K,top,cnt,ans;
int st[maxn],to[maxn],nxt[maxn],head[maxn],nt[maxn];
ll g[maxn],w[maxn],pre[maxn],suf[maxn];
ll mp[maxn<<2],sp[maxn<<2];	//max_p(p=cost-suf),max_(suf{l..j-1}+p)
ll ms[maxn<<2],tag[maxn<<2];	//max_suf
inline void add(int a,int b)
{
	to[cnt]=b,nxt[cnt]=head[a],head[a]=cnt++;
}
inline void upd(int x,ll y)
{
	tag[x]+=y,ms[x]+=y,sp[x]+=y;
}
inline void pushdown(int x)
{
	if(tag[x])
	{
		upd(lson,tag[x]),upd(rson,tag[x]);
		tag[x]=0;
	}
}
ll calc(int l,int r,int x,ll t)
{
	if(l==r)	return t+mp[x];
	int mid=(l+r)>>1;
	if(ms[lson]>=t)	return max(calc(l,mid,lson,t),sp[rson]);
	return max(t+mp[lson],calc(mid+1,r,rson,t));
}
inline void pushup(int l,int r,int x)
{
	ms[x]=max(ms[lson],ms[rson]);
	mp[x]=max(mp[lson],mp[rson]);
	int mid=(l+r)>>1;
	sp[x]=calc(mid+1,r,rson,ms[lson]);
}
void build(int l,int r,int x)
{
	if(l==r)
	{
		ms[x]=suf[l];
		mp[x]=-suf[l];
		return ;
	}
	int mid=(l+r)>>1;
	build(l,mid,lson),build(mid+1,r,rson);
	pushup(l,r,x);
}
void updata(int l,int r,int x,int a,int b,ll t)
{
	if(a>b)	return ;
	if(a<=l&&r<=b)
	{
		upd(x,t);
		return ;
	}
	pushdown(x);
	int mid=(l+r)>>1;
	if(a<=mid)	updata(l,mid,lson,a,b,t);
	if(b>mid)	updata(mid+1,r,rson,a,b,t);
	pushup(l,r,x);
}
int solve(int l,int r,int x,ll t)
{
	if(l==r)	return t+mp[x]<=K?l:0;
	pushdown(x);
	int mid=(l+r)>>1;
	if(x+mp[rson]<=K)	return solve(mid+1,r,rson,t);
	return solve(l,mid,lson,t);
}
int query(int l,int r,int x,ll t)
{
	if(l==r)	return t+mp[x]<=K?l:0;
	pushdown(x);
	int mid=(l+r)>>1;
	if(ms[lson]>=t)
	{
		if(sp[x]<=K)	return query(mid+1,r,rson,t);
		else	return query(l,mid,lson,t);
	}
	else
	{
		return max(solve(l,mid,lson,t),query(mid+1,r,rson,max(t,ms[lson])));
	}
}
void dfs(int x)
{
	if(x!=n+1)
	{
		updata(1,n,1,1,x-1,-1e17);
		updata(1,n,1,nt[x]-1,n,pre[x-1]-pre[nt[x]-1]);
		ans=max(ans,query(1,n,1,-1e17)-x+1);
		updata(1,n,1,1,x-1,1e17);
	}
	for(int i=head[x];i!=-1;i=nxt[i])	dfs(to[i]);
	if(x!=n+1)
	{
		updata(1,n,1,nt[x]-1,n,-(pre[x-1]-pre[nt[x]-1]));
	}
}
inline int rd()
{
	int ret=0,f=1;	char gc=getchar();
	while(gc<'0'||gc>'9')	{if(gc=='-')	f=-f;	gc=getchar();}
	while(gc>='0'&&gc<='9')	ret=ret*10+(gc^'0'),gc=getchar();
	return ret*f;
}
int main()
{
	memset(head,-1,sizeof(head));
	n=rd(),K=rd();
	int i;
	for(i=1;i<n;i++)	w[i]=rd();
	//w[n]=1e17;
	for(i=1;i<=n;i++)	g[i]=rd(),pre[i]=pre[i-1]+g[i]-w[i],suf[i]=suf[i-1]+g[i]-w[i-1];
	for(st[top=0]=n,i=n-1;i>=1;i--)
	{
		while(top&&pre[st[top]-1]>=pre[i-1])	top--;
		nt[i]=st[top],add(st[top],i),st[++top]=i;
	}
	build(1,n,1);
	dfs(n);
	printf("%d",ans);
	return 0;
}


#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define lson x<<1
#define rson x<<1|1
using namespace std;

const int maxn=100010;
typedef long long ll;
int n,K,top,cnt,ans;
int st[maxn],to[maxn],nxt[maxn],head[maxn],nt[maxn];
ll g[maxn],w[maxn],pre[maxn],suf[maxn];
ll mp[maxn<<2],sp[maxn<<2];	//max_p(p=cost-suf),max_(suf{l..j-1}+p)
ll ms[maxn<<2],tag[maxn<<2];	//max_suf
inline void add(int a,int b)
{
	to[cnt]=b,nxt[cnt]=head[a],head[a]=cnt++;
}
inline void upd(int x,ll y)
{
	tag[x]+=y,ms[x]+=y,sp[x]+=y;
}
inline void pushdown(int x)
{
	if(tag[x])
	{
		upd(lson,tag[x]),upd(rson,tag[x]);
		tag[x]=0;
	}
}
ll calc(int l,int r,int x,ll t)
{
	if(l==r)	return t+mp[x];
	pushdown(x);
	int mid=(l+r)>>1;
	if(ms[lson]>=t)	return min(calc(l,mid,lson,t),sp[x]);
	return min(t+mp[lson],calc(mid+1,r,rson,t));
}
inline void pushup(int l,int r,int x)
{
	ms[x]=max(ms[lson],ms[rson]);
	int mid=(l+r)>>1;
	sp[x]=calc(mid+1,r,rson,ms[lson]);
}
void build(int l,int r,int x)
{
	if(l==r)
	{
		ms[x]=suf[l];
		mp[x]=-suf[l];
		return ;
	}
	int mid=(l+r)>>1;
	build(l,mid,lson),build(mid+1,r,rson);
	pushup(l,r,x),mp[x]=max(mp[lson],mp[rson]);
}
void updata(int l,int r,int x,int a,int b,ll t)
{
	if(a>b)	return ;
	if(a<=l&&r<=b)
	{
		upd(x,t);
		return ;
	}
	pushdown(x);
	int mid=(l+r)>>1;
	if(a<=mid)	updata(l,mid,lson,a,b,t);
	if(b>mid)	updata(mid+1,r,rson,a,b,t);
	pushup(l,r,x);
}
int solve(int l,int r,int x,ll t)
{
	if(l==r)	return t+mp[x]<=K?l:0;
	pushdown(x);
	int mid=(l+r)>>1;
	if(x+mp[rson]<=K)	return solve(mid+1,r,rson,t);
	return solve(l,mid,lson,t);
}
int query(int l,int r,int x,ll t)
{
	if(l==r)	return t+mp[x]<=K?l:0;
	pushdown(x);
	int mid=(l+r)>>1;
	if(ms[lson]>=t)
	{
		if(sp[x]<=K)	return query(mid+1,r,rson,ms[lson]);
		else	return query(l,mid,lson,t);
	}
	else
	{
		return max(solve(l,mid,lson,t),query(mid+1,r,rson,t));
	}
}
void init(int l,int r,int x)
{
	if(l==r)	return ;
	pushdown(x);
	int mid=(l+r)>>1;
	init(l,mid,lson),init(mid+1,r,rson);
}
void dfs(int x)
{
	if(x!=n+1)
	{
		updata(1,n,1,1,x-1,-1e17);
		updata(1,n,1,nt[x]-1,n,pre[x-1]-pre[nt[x]-1]);
		init(1,n,1);
		ans=max(ans,query(1,n,1,-1e17)-x+1);
		updata(1,n,1,1,x-1,1e17);
	}
	for(int i=head[x];i!=-1;i=nxt[i])	dfs(to[i]);
	if(x!=n+1)
	{
		updata(1,n,1,nt[x],n,-(pre[x-1]-pre[nt[x]-1]));
	}
}
inline int rd()
{
	int ret=0,f=1;	char gc=getchar();
	while(gc<'0'||gc>'9')	{if(gc=='-')	f=-f;	gc=getchar();}
	while(gc>='0'&&gc<='9')	ret=ret*10+(gc^'0'),gc=getchar();
	return ret*f;
}
int main()
{
	memset(head,-1,sizeof(head));
	n=rd(),K=rd();
	int i;
	for(i=1;i<n;i++)	w[i]=rd();
	w[n]=1e17;
	for(i=1;i<=n;i++)	g[i]=rd(),pre[i]=pre[i-1]+g[i]-w[i],suf[i]=suf[i-1]+g[i]-w[i-1];
	for(st[top=0]=n,i=n-1;i>=0;i--)
	{
		while(top&&pre[st[top]]>=pre[i])	top--;
		nt[i+1]=st[top]+1,add(st[top]+1,i+1),st[++top]=i;
	}
	build(1,n,1);
	dfs(n+1);
	printf("%d",ans);
	return 0;
}


#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define lson x<<1
#define rson x<<1|1
using namespace std;

const int maxn=100010;
typedef long long ll;
int n,K,top,cnt,ans;
int st[maxn],to[maxn],nxt[maxn],head[maxn],nt[maxn];
ll g[maxn],w[maxn],pre[maxn],suf[maxn];
ll mp[maxn<<2],sp[maxn<<2];	//max_p(p=cost-suf),max_(suf{l..j-1}+p)
ll ms[maxn<<2],tag[maxn<<2];	//max_suf
inline void add(int a,int b)
{
	to[cnt]=b,nxt[cnt]=head[a],head[a]=cnt++;
}
inline void upd(int x,ll y)
{
	tag[x]+=y,ms[x]+=y,sp[x]+=y;
}
inline void pushdown(int x)
{
	if(tag[x])
	{
		upd(lson,tag[x]),upd(rson,tag[x]);
		tag[x]=0;
	}
}
ll calc(int l,int r,int x,ll t)
{
	if(l==r)	return t+mp[x];
	pushdown(x);
	int mid=(l+r)>>1;
	if(ms[lson]>=t)	return min(calc(l,mid,lson,t),sp[x]);
	return min(t+mp[lson],calc(mid+1,r,rson,t));
}
inline void pushup(int l,int r,int x)
{
	ms[x]=max(ms[lson],ms[rson]);
	int mid=(l+r)>>1;
	sp[x]=calc(mid+1,r,rson,ms[lson]);
}
void build(int l,int r,int x)
{
	if(l==r)
	{
		ms[x]=suf[l];
		mp[x]=-suf[l];
		return ;
	}
	int mid=(l+r)>>1;
	build(l,mid,lson),build(mid+1,r,rson);
	pushup(l,r,x),mp[x]=max(mp[lson],mp[rson]);
}
void updata(int l,int r,int x,int a,int b,ll t)
{
	if(a>b)	return ;
	if(a<=l&&r<=b)
	{
		upd(x,t);
		return ;
	}
	pushdown(x);
	int mid=(l+r)>>1;
	if(a<=mid)	updata(l,mid,lson,a,b,t);
	if(b>mid)	updata(mid+1,r,rson,a,b,t);
	pushup(l,r,x);
}
int solve(int l,int r,int x,ll t)
{
	if(l==r)	return t+mp[x]<=K?l:0;
	pushdown(x);
	int mid=(l+r)>>1;
	if(x+mp[rson]<=K)	return solve(mid+1,r,rson,t);
	return solve(l,mid,lson,t);
}
int query(int l,int r,int x,ll t)
{
	if(l==r)	return t+mp[x]<=K?l:0;
	pushdown(x);
	int mid=(l+r)>>1;
	if(ms[lson]>=t)
	{
		if(sp[x]<=K)	return query(mid+1,r,rson,ms[lson]);
		else	return query(l,mid,lson,t);
	}
	else
	{
		return max(solve(l,mid,lson,t),query(mid+1,r,rson,t));
	}
}
void init(int l,int r,int x)
{
	if(l==r)	return ;
	pushdown(x);
	int mid=(l+r)>>1;
	init(l,mid,lson),init(mid+1,r,rson);
}
void dfs(int x)
{
	if(x!=n+1)
	{
		updata(1,n,1,1,x-1,-1e17);
		updata(1,n,1,nt[x]-1,n,pre[x-1]-pre[nt[x]-1]);
		ans=max(ans,query(1,n,1,-1e17)-x+1);
		updata(1,n,1,1,x-1,1e17);
	}
	for(int i=head[x];i!=-1;i=nxt[i])	dfs(to[i]);
	if(x!=n+1)
	{
		updata(1,n,1,nt[x],n,-(pre[x-1]-pre[nt[x]-1]));
	}
}
inline int rd()
{
	int ret=0,f=1;	char gc=getchar();
	while(gc<'0'||gc>'9')	{if(gc=='-')	f=-f;	gc=getchar();}
	while(gc>='0'&&gc<='9')	ret=ret*10+(gc^'0'),gc=getchar();
	return ret*f;
}
int main()
{
	memset(head,-1,sizeof(head));
	n=rd(),K=rd();
	int i;
	for(i=1;i<n;i++)	w[i]=rd();
	w[n]=1e17;
	for(i=1;i<=n;i++)	g[i]=rd(),pre[i]=pre[i-1]+g[i]-w[i],suf[i]=suf[i-1]+g[i]-w[i-1];
	for(st[top=0]=n,i=n-1;i>=0;i--)
	{
		while(top&&pre[st[top]]>=pre[i])	top--;
		nt[i+1]=st[top]+1,add(st[top]+1,i+1),st[++top]=i;
	}
	build(1,n,1);
	dfs(n+1);
	printf("%d",ans);
	return 0;
}


#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define lson x<<1
#define rson x<<1|1
using namespace std;

const int maxn=100010;
typedef long long ll;
int n,K,top,cnt,ans;
int st[maxn],to[maxn],nxt[maxn],head[maxn],nt[maxn];
ll g[maxn],w[maxn],pre[maxn],suf[maxn];
ll mp[maxn<<2],sp[maxn<<2];	//max_p(p=cost-suf),max_(suf{l..j-1}+p)
ll ms[maxn<<2],tag[maxn<<2];	//max_suf
inline void add(int a,int b)
{
	to[cnt]=b,nxt[cnt]=head[a],head[a]=cnt++;
}
inline void upd(int x,ll y)
{
	tag[x]+=y,ms[x]+=y,sp[x]+=y;
}
inline void pushdown(int x)
{
	if(tag[x])
	{
		upd(lson,tag[x]),upd(rson,tag[x]);
		tag[x]=0;
	}
}
ll calc(int l,int r,int x,ll t)
{
	if(l==r)	return t+mp[x];
	pushdown(x);
	int mid=(l+r)>>1;
	if(ms[lson]>=t)	return min(calc(l,mid,lson,t),sp[x]);
	return min(t+mp[lson],calc(mid+1,r,rson,t));
}
inline void pushup(int l,int r,int x)
{
	ms[x]=max(ms[lson],ms[rson]);
	int mid=(l+r)>>1;
	sp[x]=calc(mid+1,r,rson,ms[lson]);
}
void build(int l,int r,int x)
{
	if(l==r)
	{
		ms[x]=suf[l];
		mp[x]=-suf[l];
		return ;
	}
	int mid=(l+r)>>1;
	build(l,mid,lson),build(mid+1,r,rson);
	pushup(l,r,x),mp[x]=min(mp[lson],mp[rson]);
}
void updata(int l,int r,int x,int a,int b,ll t)
{
	if(a>b)	return ;
	if(a<=l&&r<=b)
	{
		upd(x,t);
		return ;
	}
	pushdown(x);
	int mid=(l+r)>>1;
	if(a<=mid)	updata(l,mid,lson,a,b,t);
	if(b>mid)	updata(mid+1,r,rson,a,b,t);
	pushup(l,r,x);
}
int solve(int l,int r,int x,ll t)
{
	if(l==r)	return t+mp[x]<=K?l:0;
	pushdown(x);
	int mid=(l+r)>>1;
	if(t+mp[rson]<=K)	return solve(mid+1,r,rson,t);
	return solve(l,mid,lson,t);
}
int query(int l,int r,int x,ll t)
{
	if(l==r)	return t+mp[x]<=K?l:0;
	pushdown(x);
	int mid=(l+r)>>1;
	if(ms[lson]>=t)
	{
		if(sp[x]<=K)	return query(mid+1,r,rson,ms[lson]);
		else	return query(l,mid,lson,t);
	}
	else
	{
		return max(solve(l,mid,lson,t),query(mid+1,r,rson,t));
	}
}
void init(int l,int r,int x)
{
	if(l==r)	return ;
	pushdown(x);
	int mid=(l+r)>>1;
	init(l,mid,lson),init(mid+1,r,rson);
}
void dfs(int x)
{
	st[++top]=x;
	if(x!=n+1)
	{
		updata(1,n,1,1,x-1,-1e17);
		updata(1,n,1,nt[x]-1,n,pre[x-1]-pre[nt[x]-1]);
		int l=1,r=top,mid;
		while(l<r)
		{
			mid=(l+r)>>1;
			if(pre[x-1]-pre[st[mid]-1]<=K)	r=mid;
			else	l=mid+1;
		}
		updata(1,n,1,st[r-1],n,1e17);
		ans=max(ans,query(1,n,1,-1e17)-x+1);
		updata(1,n,1,st[r-1],n,-1e17);
		updata(1,n,1,1,x-1,1e17);
	}
	for(int i=head[x];i!=-1;i=nxt[i])	dfs(to[i]);
	if(x!=n+1)
	{
		updata(1,n,1,nt[x]-1,n,-(pre[x-1]-pre[nt[x]-1]));
	}
	top--;
}
inline int rd()
{
	int ret=0,f=1;	char gc=getchar();
	while(gc<'0'||gc>'9')	{if(gc=='-')	f=-f;	gc=getchar();}
	while(gc>='0'&&gc<='9')	ret=ret*10+(gc^'0'),gc=getchar();
	return ret*f;
}
int main()
{
	memset(head,-1,sizeof(head));
	n=rd(),K=rd();
	int i;
	for(i=1;i<n;i++)	w[i]=rd();
	w[n]=1e17;
	for(i=1;i<=n;i++)	g[i]=rd(),pre[i]=pre[i-1]+g[i]-w[i],suf[i]=suf[i-1]+g[i]-w[i-1];
	for(st[top=0]=n,i=n-1;i>=0;i--)
	{
		while(top&&pre[st[top]]>=pre[i])	top--;
		nt[i+1]=st[top]+1,add(st[top]+1,i+1),st[++top]=i;
	}
	build(1,n,1);
	top=0,dfs(n+1);
	printf("%d",ans);
	return 0;
}


#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define lson x<<1
#define rson x<<1|1
using namespace std;

const int maxn=100010;
typedef long long ll;
int n,K,top,cnt,ans;
int st[maxn],to[maxn],nxt[maxn],head[maxn],nt[maxn];
ll g[maxn],w[maxn],pre[maxn],suf[maxn];
ll mp[maxn<<2],sp[maxn<<2];	//max_p(p=cost-suf),max_(suf{l..j-1}+p)
ll ms[maxn<<2],tag[maxn<<2];	//max_suf
inline void add(int a,int b)
{
	to[cnt]=b,nxt[cnt]=head[a],head[a]=cnt++;
}
inline void upd(int x,ll y)
{
	tag[x]+=y,ms[x]+=y,sp[x]+=y;
}
inline void pushdown(int x)
{
	if(tag[x])
	{
		upd(lson,tag[x]),upd(rson,tag[x]);
		tag[x]=0;
	}
}
ll calc(int l,int r,int x,ll t)
{
	if(l==r)	return t+mp[x];
	pushdown(x);
	int mid=(l+r)>>1;
	if(ms[lson]>=t)	return min(calc(l,mid,lson,t),sp[x]);
	return min(t+mp[lson],calc(mid+1,r,rson,t));
}
inline void pushup(int l,int r,int x)
{
	ms[x]=max(ms[lson],ms[rson]);
	int mid=(l+r)>>1;
	sp[x]=calc(mid+1,r,rson,ms[lson]);
}
void build(int l,int r,int x)
{
	if(l==r)
	{
		ms[x]=suf[l];
		mp[x]=-suf[l];
		return ;
	}
	int mid=(l+r)>>1;
	build(l,mid,lson),build(mid+1,r,rson);
	pushup(l,r,x),mp[x]=max(mp[lson],mp[rson]);
}
void updata(int l,int r,int x,int a,int b,ll t)
{
	if(a>b)	return ;
	if(a<=l&&r<=b)
	{
		upd(x,t);
		return ;
	}
	pushdown(x);
	int mid=(l+r)>>1;
	if(a<=mid)	updata(l,mid,lson,a,b,t);
	if(b>mid)	updata(mid+1,r,rson,a,b,t);
	pushup(l,r,x);
}
int solve(int l,int r,int x,ll t)
{
	if(l==r)	return t+mp[x]<=K?l:0;
	pushdown(x);
	int mid=(l+r)>>1;
	if(t+mp[rson]<=K)	return solve(mid+1,r,rson,t);
	return solve(l,mid,lson,t);
}
int query(int l,int r,int x,ll t)
{
	if(l==r)	return t+mp[x]<=K?l:0;
	pushdown(x);
	int mid=(l+r)>>1;
	if(ms[lson]>=t)
	{
		if(sp[x]<=K)	return query(mid+1,r,rson,ms[lson]);
		else	return query(l,mid,lson,t);
	}
	else
	{
		return max(solve(l,mid,lson,t),query(mid+1,r,rson,t));
	}
}
void init(int l,int r,int x)
{
	if(l==r)	return ;
	pushdown(x);
	int mid=(l+r)>>1;
	init(l,mid,lson),init(mid+1,r,rson);
}
void dfs(int x)
{
	if(x!=n+1)
	{
		updata(1,n,1,1,x-1,-1e17);
		updata(1,n,1,nt[x]-1,n,pre[x-1]-pre[nt[x]-1]);
		ans=max(ans,query(1,n,1,-1e17)-x+1);
		updata(1,n,1,1,x-1,1e17);
	}
	for(int i=head[x];i!=-1;i=nxt[i])	dfs(to[i]);
	if(x!=n+1)
	{
		updata(1,n,1,nt[x]-1,n,-(pre[x-1]-pre[nt[x]-1]));
	}
}
inline int rd()
{
	int ret=0,f=1;	char gc=getchar();
	while(gc<'0'||gc>'9')	{if(gc=='-')	f=-f;	gc=getchar();}
	while(gc>='0'&&gc<='9')	ret=ret*10+(gc^'0'),gc=getchar();
	return ret*f;
}
int main()
{
	memset(head,-1,sizeof(head));
	n=rd(),K=rd();
	int i;
	for(i=1;i<n;i++)	w[i]=rd();
	w[n]=1e17;
	for(i=1;i<=n;i++)	g[i]=rd(),pre[i]=pre[i-1]+g[i]-w[i],suf[i]=suf[i-1]+g[i]-w[i-1];
	for(st[top=0]=n,i=n-1;i>=0;i--)
	{
		while(top&&pre[st[top]]>=pre[i])	top--;
		nt[i+1]=st[top]+1,add(st[top]+1,i+1),st[++top]=i;
	}
	build(1,n,1);
	dfs(n+1);
	printf("%d",ans);
	return 0;
}


#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define lson x<<1
#define rson x<<1|1
using namespace std;

const int maxn=100010;
typedef long long ll;
int n,K,top,cnt,ans;
int st[maxn],to[maxn],nxt[maxn],head[maxn],nt[maxn];
ll g[maxn],w[maxn],pre[maxn],suf[maxn];
ll mp[maxn<<2],sp[maxn<<2];	//max_p(p=cost-suf),max_(suf{l..j-1}+p)
ll ms[maxn<<2],tag[maxn<<2];	//max_suf
inline void add(int a,int b)
{
	to[cnt]=b,nxt[cnt]=head[a],head[a]=cnt++;
}
inline void upd(int x,ll y)
{
	tag[x]+=y,ms[x]+=y,sp[x]+=y;
}
inline void pushdown(int x)
{
	if(tag[x])
	{
		upd(lson,tag[x]),upd(rson,tag[x]);
		tag[x]=0;
	}
}
ll calc(int l,int r,int x,ll t)
{
	if(l==r)	return t+mp[x];
	pushdown(x);
	int mid=(l+r)>>1;
	if(ms[lson]>=t)	return min(calc(l,mid,lson,t),sp[x]);
	return min(t+mp[lson],calc(mid+1,r,rson,t));
}
inline void pushup(int l,int r,int x)
{
	ms[x]=max(ms[lson],ms[rson]);
	int mid=(l+r)>>1;
	sp[x]=calc(mid+1,r,rson,ms[lson]);
}
void build(int l,int r,int x)
{
	if(l==r)
	{
		ms[x]=suf[l];
		mp[x]=-suf[l];
		return ;
	}
	int mid=(l+r)>>1;
	build(l,mid,lson),build(mid+1,r,rson);
	pushup(l,r,x),mp[x]=min(mp[lson],mp[rson]);
}
void updata(int l,int r,int x,int a,int b,ll t)
{
	if(a>b)	return ;
	if(a<=l&&r<=b)
	{
		upd(x,t);
		return ;
	}
	pushdown(x);
	int mid=(l+r)>>1;
	if(a<=mid)	updata(l,mid,lson,a,b,t);
	if(b>mid)	updata(mid+1,r,rson,a,b,t);
	pushup(l,r,x);
}
int solve(int l,int r,int x,ll t)
{
	if(l==r)	return t+mp[x]<=K?l:0;
	pushdown(x);
	int mid=(l+r)>>1;
	if(t+mp[rson]<=K)	return solve(mid+1,r,rson,t);
	return solve(l,mid,lson,t);
}
int query(int l,int r,int x,ll t)
{
	if(l==r)	return t+mp[x]<=K?l:0;
	pushdown(x);
	int mid=(l+r)>>1;
	if(ms[lson]>=t)
	{
		if(sp[x]<=K)	return query(mid+1,r,rson,ms[lson]);
		else	return query(l,mid,lson,t);
	}
	else
	{
		return max(solve(l,mid,lson,t),query(mid+1,r,rson,t));
	}
}
void init(int l,int r,int x)
{
	if(l==r)	return ;
	pushdown(x);
	int mid=(l+r)>>1;
	init(l,mid,lson),init(mid+1,r,rson);
}
void dfs(int x)
{
	if(x!=n+1)
	{
		updata(1,n,1,1,x-1,-1e18);
		updata(1,n,1,nt[x]-1,n,pre[x-1]-pre[nt[x]-1]);
		ans=max(ans,query(1,n,1,-1e18)-x+1);
		updata(1,n,1,1,x-1,1e18);
	}
	for(int i=head[x];i!=-1;i=nxt[i])	dfs(to[i]);
	if(x!=n+1)
	{
		updata(1,n,1,nt[x]-1,n,-(pre[x-1]-pre[nt[x]-1]));
	}
}
inline int rd()
{
	int ret=0,f=1;	char gc=getchar();
	while(gc<'0'||gc>'9')	{if(gc=='-')	f=-f;	gc=getchar();}
	while(gc>='0'&&gc<='9')	ret=ret*10+(gc^'0'),gc=getchar();
	return ret*f;
}
int main()
{
	memset(head,-1,sizeof(head));
	n=rd(),K=rd();
	int i;
	for(i=1;i<n;i++)	w[i]=rd();
	w[n]=1e18;
	for(i=1;i<=n;i++)	g[i]=rd(),pre[i]=pre[i-1]+g[i]-w[i],suf[i]=suf[i-1]+g[i]-w[i-1];
	for(st[top=0]=n,i=n-1;i>=0;i--)
	{
		while(top&&pre[st[top]]>=pre[i])	top--;
		nt[i+1]=st[top]+1,add(st[top]+1,i+1),st[++top]=i;
	}
	build(1,n,1);
	dfs(n+1);
	printf("%d",ans);
	return 0;
}


#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define lson x<<1
#define rson x<<1|1
using namespace std;

const int maxn=100010;
typedef long long ll;
int n,K,top,cnt,ans;
int st[maxn],to[maxn],nxt[maxn],head[maxn],nt[maxn];
ll g[maxn],w[maxn],pre[maxn],suf[maxn];
ll mp[maxn<<2],sp[maxn<<2];	//max_p(p=cost-suf),max_(suf{l..j-1}+p)
ll ms[maxn<<2],tag[maxn<<2];	//max_suf
inline void add(int a,int b)
{
	to[cnt]=b,nxt[cnt]=head[a],head[a]=cnt++;
}
inline void upd(int x,ll y)
{
	tag[x]+=y,ms[x]+=y,sp[x]+=y;
}
inline void pushdown(int x)
{
	if(tag[x])
	{
		upd(lson,tag[x]),upd(rson,tag[x]);
		tag[x]=0;
	}
}
ll calc(int l,int r,int x,ll t)
{
	if(l==r)	return t+mp[x];
	pushdown(x);
	int mid=(l+r)>>1;
	if(ms[lson]>=t)	return min(calc(l,mid,lson,t),sp[x]);
	return min(t+mp[lson],calc(mid+1,r,rson,t));
}
inline void pushup(int l,int r,int x)
{
	ms[x]=max(ms[lson],ms[rson]);
	int mid=(l+r)>>1;
	sp[x]=calc(mid+1,r,rson,ms[lson]);
}
void build(int l,int r,int x)
{
	if(l==r)
	{
		ms[x]=suf[l];
		mp[x]=-suf[l];
		return ;
	}
	int mid=(l+r)>>1;
	build(l,mid,lson),build(mid+1,r,rson);
	pushup(l,r,x),mp[x]=max(mp[lson],mp[rson]);
}
void updata(int l,int r,int x,int a,int b,ll t)
{
	if(a>b)	return ;
	if(a<=l&&r<=b)
	{
		upd(x,t);
		return ;
	}
	pushdown(x);
	int mid=(l+r)>>1;
	if(a<=mid)	updata(l,mid,lson,a,b,t);
	if(b>mid)	updata(mid+1,r,rson,a,b,t);
	pushup(l,r,x);
}
int solve(int l,int r,int x,ll t)
{
	if(l==r)	return t+mp[x]<=K?l:0;
	pushdown(x);
	int mid=(l+r)>>1;
	if(t+mp[rson]<=K)	return solve(mid+1,r,rson,t);
	return solve(l,mid,lson,t);
}
int query(int l,int r,int x,ll t)
{
	if(l==r)	return t+mp[x]<=K?l:0;
	pushdown(x);
	int mid=(l+r)>>1;
	if(ms[lson]>=t)
	{
		if(sp[x]<=K)	return query(mid+1,r,rson,ms[lson]);
		else	return query(l,mid,lson,t);
	}
	else
	{
		return max(solve(l,mid,lson,t),query(mid+1,r,rson,t));
	}
}
void init(int l,int r,int x)
{
	if(l==r)	return ;
	pushdown(x);
	int mid=(l+r)>>1;
	init(l,mid,lson),init(mid+1,r,rson);
}
void dfs(int x)
{
	if(x!=n+1)
	{
		updata(1,n,1,1,x-1,-1e17);
		updata(1,n,1,nt[x]-1,n,pre[x-1]-pre[nt[x]-1]);
		ans=max(ans,query(1,n,1,-1e17)-x+1);
		updata(1,n,1,1,x-1,1e17);
	}
	for(int i=head[x];i!=-1;i=nxt[i])	dfs(to[i]);
	if(x!=n+1)
	{
		updata(1,n,1,nt[x],n,-(pre[x-1]-pre[nt[x]-1]));
	}
}
inline int rd()
{
	int ret=0,f=1;	char gc=getchar();
	while(gc<'0'||gc>'9')	{if(gc=='-')	f=-f;	gc=getchar();}
	while(gc>='0'&&gc<='9')	ret=ret*10+(gc^'0'),gc=getchar();
	return ret*f;
}
int main()
{
	memset(head,-1,sizeof(head));
	n=rd(),K=rd();
	int i;
	for(i=1;i<n;i++)	w[i]=rd();
	w[n]=1e17;
	for(i=1;i<=n;i++)	g[i]=rd(),pre[i]=pre[i-1]+g[i]-w[i],suf[i]=suf[i-1]+g[i]-w[i-1];
	for(st[top=0]=n,i=n-1;i>=0;i--)
	{
		while(top&&pre[st[top]]>=pre[i])	top--;
		nt[i+1]=st[top]+1,add(st[top]+1,i+1),st[++top]=i;
	}
	build(1,n,1);
	dfs(n+1);
	printf("%d",ans);
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int MAX_N = 1e5 + 10;
const ll INF = 1e16;

int N, fail[MAX_N], ans = 1;
ll K, W[MAX_N], G[MAX_N], delta_r[MAX_N], delta_l[MAX_N], need[MAX_N];
vector<int> child[MAX_N];

struct SegTreeAux {
    int l, r, m;
    SegTreeAux *cl, *cr;
    ll v;

    SegTreeAux(int l, int r) : l(l), r(r), m((l + r) / 2), cl(nullptr), cr(nullptr), v(0) {
        if (l != r) {
            cl = new SegTreeAux(l, m);
            cr = new SegTreeAux(m + 1, r);
        }
    }

    void modify_add(int x, ll y) {
        v += y;
        if (l == r) return;
        (x <= m ? cl : cr)->modify_add(x, y);
    }

    int upper_bound(int x, int y) {
        if (r < x) return 0;
        if (x <= l && v <= y) return -v;
        if (l == r) return l;
        int tl = cl->upper_bound(x, y);
        if (tl > 0) return tl;
        y += tl;
        int tr = cr->upper_bound(x, y);
        if (tr > 0) return tr;
        return tl + tr;
    }
} *segt_aux;

struct SegTree *segt;

struct SegTree {
    int l, r, m;
    SegTree *cl, *cr;
    ll a_min, b_max, b_lazy, f_ch;

    SegTree(int l, int r) : l(l), r(r), m((l + r) / 2), cl(nullptr), cr(nullptr), a_min(0), b_max(0), b_lazy(0), f_ch(0) {
        if (l != r) {
            cl = new SegTree(l, m);
            cr = new SegTree(m + 1, r);
            update();
        } else {
            a_min = -delta_l[l];
            b_max = delta_l[l];
        }
    }

    void pushdown() {
        if (!b_lazy) return;
        b_max += b_lazy;
        if (l != r) {
            cl->b_lazy += b_lazy;
            cr->b_lazy += b_lazy;
            f_ch += b_lazy;
        }
        b_lazy = 0;
    }

    void update() {
        cl->pushdown();
        cr->pushdown();
        a_min = min(cl->a_min, cr->a_min);
        b_max = max(cl->b_max, cr->b_max);
        f_ch = cr->query_f_min(cl->b_max);
    }

    ll query_f_min(ll pre_b_max) {
        if (l == r) {
            return pre_b_max + a_min;
        }
        pushdown();
        cl->pushdown();
        if (pre_b_max <= cl->b_max) {
            return min(cl->query_f_min(pre_b_max), f_ch);
        } else {
            return min(cl->a_min + pre_b_max, cr->query_f_min(pre_b_max));
        }
    }

    void modify_add_b(int ql, int qr, ll qv) {
        if (qr < l || ql > r) return;
        if (ql <= l && qr >= r) {
            b_lazy += qv;
        } else {
            pushdown();
            cl->modify_add_b(ql, qr, qv);
            cr->modify_add_b(ql, qr, qv);
            update();
        }
    }

    ll query_b_max(int ql, int qr) {
        if (qr < l || ql > r) return -INF;
        pushdown();
        if (ql <= l && qr >= r) return b_max;
        return max(cl->query_b_max(ql, qr), cr->query_b_max(ql, qr));
    }

    int upper_bound(int ql, int qr, ll threshold) {
        if (qr < l || ql > r) return -1;
        pushdown();
        if (ql <= l && qr >= r) {
            ll pre_b_max = segt->query_b_max(ql, l - 1);
            ll t = query_f_min(pre_b_max);
            if (t > threshold) return -1;
        }
        if (l == r) return l;
        int t = cr->upper_bound(ql, qr, threshold);
        if (t != -1) return t;
        return cl->upper_bound(ql, qr, threshold);
    }
};

void init() {
    scanf("%d%lld", &N, &K);
    for (int i = 1; i < N; i++) scanf("%lld", &W[i]);
    for (int i = 1; i <= N; i++) scanf("%lld", &G[i]);
    for (int i = 1; i <= N; i++) delta_r[i] = delta_r[i - 1] + G[i - 1] - W[i - 1];
    stack<pair<int, ll>> stk; stk.emplace(N + 1, -INF);
    for (int i = N; i; i--) {
        while (delta_r[i] <= stk.top().second) stk.pop();
        child[fail[i] = stk.top().first].push_back(i);
        need[i] = delta_r[i] - stk.top().second;
        stk.emplace(i, delta_r[i]);
    }
    for (int i = 1; i <= N; i++) {
        delta_l[i] = delta_l[i - 1] + G[i] - W[i - 1];
    }
    segt_aux = new SegTreeAux(1, N);
    segt = new SegTree(1, N);
}

void solve(int x) {
    segt_aux->modify_add(fail[x] - 1, need[x]);
    segt->modify_add_b(fail[x] - 1, N, need[x]);
    int r = segt_aux->upper_bound(x, K);
    int res = segt->upper_bound(x, r, K);
    ans = max(ans, res - x + 1);
    for (int i : child[x]) {
        solve(i);
    }
    segt_aux->modify_add(fail[x] - 1, -need[x]);
    segt->modify_add_b(fail[x] - 1, N, -need[x]);
}

int main() {
    init();
    for (int i : child[N + 1]) {
        solve(i);
    }
    printf("%d\n", ans);
}


#include <bits/stdc++.h>
#define inf 1e15
using namespace std;

int read();

int n, K;
int st[200005], nxt[200005];
long long pre[200005], suf[200005], W[200005], g[200005], root;
int res;
vector<int> e[200005];

struct Seg {
    long long Minp[800005], Maxs[800005], ans[800005], tag[800005];
    void Add(int o, long long v) {
        Maxs[o] += v;
        tag[o] += v;
        ans[o] += v;
        return;
    }
    void psd(int o) {
        if (tag[o]) Add(o << 1, tag[o]), Add(o << 1 | 1, tag[o]), tag[o] = 0;
    }
    long long Calc(int o, int l, int r, long long x) {
        if (l == r) return x + Minp[o];
        int mid = (l + r) >> 1;
        psd(o);
        long long y = Maxs[o << 1];
        if (x >= y)
            return min(x + Minp[o << 1], Calc(o << 1 | 1, mid + 1, r, x));
        else
            return min(ans[o], Calc(o << 1, l, mid, x));
    }
    void PushUp(int o, int l, int r) {
        Maxs[o] = max(Maxs[o << 1], Maxs[o << 1 | 1]);
        int mid = (l + r) >> 1;
        ans[o] = Calc(o << 1 | 1, mid + 1, r, Maxs[o << 1]);
    }
    void Build(int o, int l, int r) {
        if (l == r) {
            Minp[o] = -suf[l];
            Maxs[o] = suf[l];
            ans[o] = 0;
            return;
        }
        int mid = (l + r) >> 1;
        Build(o << 1, l, mid);
        Build(o << 1 | 1, mid + 1, r);
        PushUp(o, l, r);
        Minp[o] = min(Minp[o << 1], Minp[o << 1 | 1]);
    }
    void Insert(int o, int l, int r, int ql, int qr, long long v) {
        if (ql <= l && r <= qr) {
            Add(o, v);
            return;
        }
        int mid = (l + r) >> 1;
        psd(o);
        if (ql <= mid) Insert(o << 1, l, mid, ql, qr, v);
        if (qr > mid) Insert(o << 1 | 1, mid + 1, r, ql, qr, v);
        PushUp(o, l, r);
    }
    int Solve(int o, int l, int r, long long x) {
        if (l == r) return x + Minp[o] <= K ? l : 0;
        int mid = (l + r) >> 1;
        psd(o);
        if (x + Minp[o << 1 | 1] <= K)
            return Solve(o << 1 | 1, mid + 1, r, x);
        else
            return Solve(o << 1, l, mid, x);
    }
    int Query(int o, int l, int r, long long x) {
        if (l == r) {
            return x + Minp[o] <= K ? l : 0;
        }
        int mid = (l + r) >> 1;
        psd(o);
        long long y = Maxs[o << 1];
        int ret = 0;
        if (x >= y) {
            ret = Query(o << 1 | 1, mid + 1, r, x);
            if (x + Minp[o] <= K) ret = max(ret, Solve(o << 1, l, mid, x));
        } else if (x <= y) {
            if (ans[o] <= K)
                ret = Query(o << 1 | 1, mid + 1, r, y);
            else
                ret = Query(o << 1, l, mid, x);
        }
        return ret;
    }
} seg;

void Pre() {
    st[0] = 0;
    for (int i = n; i >= 1; i--) {
        while (st[0] && pre[i - 1] <= pre[st[st[0]] - 1]) --st[0];
        nxt[i] = st[0] ? st[st[0]] : n + 1;
        st[++st[0]] = i;
    }
    root = n + 1;
    nxt[root] = n + 1;
    for (int i = 1; i <= n; i++) e[nxt[i]].push_back(i);
    return;
}
int Bipart(int x) {
    int l = 2, r = st[0], ret = 1;
    while (l <= r) {
        int mid = (l + r) >> 1;
        (pre[x - 1] - pre[st[mid] - 1] <= K) ? (ret = mid, r = mid - 1)
                                             : l = mid + 1;
    }
    return st[ret - 1] - 1;
}
void Dfs(int u, int From) {
    st[++st[0]] = u;
    if (nxt[u] <= n)
        seg.Insert(1, 1, n, nxt[u] - 1, n, pre[u - 1] - pre[nxt[u] - 1]);
    if (u <= n) {
        int r = Bipart(u);
        if (r < n) seg.Insert(1, 1, n, r, n, inf);
        if (u != 1) seg.Insert(1, 1, n, 1, u - 1, -inf);
        res = max(res, seg.Query(1, 1, n, -inf) - u + 1);
        if (r < n) seg.Insert(1, 1, n, r, n, -inf);
        if (u != 1) seg.Insert(1, 1, n, 1, u - 1, inf);
    }
    for (auto v : e[u])
        if (v != From) Dfs(v, u);
    --st[0];
    if (nxt[u] <= n)
        seg.Insert(1, 1, n, nxt[u] - 1, n, pre[nxt[u] - 1] - pre[u - 1]);
}

int main() {
    n = read(), K = read();
    for (int i = 1; i < n; i++) W[i] = read();
    W[n] = inf;
    for (int i = 1; i <= n; i++) g[i] = read();
    for (int i = 1; i <= n; i++) pre[i] = pre[i - 1] + g[i] - W[i];
    for (int i = 1; i <= n; i++) suf[i] = suf[i - 1] + g[i] - W[i - 1];
    Pre(), seg.Build(1, 1, n), st[0] = 0, Dfs(root, 0);
    printf("%d\n", res);
    return 0;
}

const int _SIZE = 1 << 22;
char ibuf[_SIZE], *iS = ibuf, *iT = ibuf;
#define gc                                                         \
    (iS == iT ? iT = ((iS = ibuf) + fread(ibuf, 1, _SIZE, stdin)), \
     (iS == iT ? EOF : *iS++) : *iS++)
int read() {
    int x = 0, f = 1;
    char c = gc;
    while (!isdigit(c)) f = (c == '-') ? -1 : f, c = gc;
    while (isdigit(c)) x = x * 10 + c - '0', c = gc;
    return x * f;
}