#include<bits/stdc++.h>

#define ll long long
#define pp push_back
#define endl '\n'
#define all(x) x.begin(),x.end()
#define ld long double
#define PI acos(-1)
#define ones(x) __builtin_popcountll(x)
//#define int ll

using namespace std;

void Drakon() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
#ifdef Clion
    freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout);
#endif
}

unsigned long long inf = 1e10;
const double EPS = 1e-6;
const int MOD = 1000000007, N = 200005, LOG = 25;

ll mul(const ll &a, const ll &b) {
    return (a % MOD + MOD) * (b % MOD + MOD) % MOD;
}

ll add(const ll &a, const ll &b) {
    return (a + b + 2 * MOD) % MOD;
}

ll pw(ll x, ll y) {
    ll ret = 1;
    while (y > 0) {
        if (y % 2 == 0) {
            x = mul(x, x);
            y = y / 2;
        } else {
            ret = mul(ret, x);
            y = y - 1;
        }
    }
    return ret;
}

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

ll sumNeg = 0, e;
multiset<int> neg, pos;
ordered_set<pair<ll, int>> pres;
vector<ll> pre;

void add(int a, int b, int i) {
    if((b - a) >= 0) {
        pos.insert(a);
    }
    else {
        sumNeg += b - a;
        neg.insert(b);
    }
    pres.insert({pre[i], i});
}

void rem(int a, int b, int i) {
    if((b - a) >= 0) {
        pos.erase(pos.find(a));
    }
    else {
        sumNeg -= b - a;
        neg.erase(neg.find(b));
    }
    pres.erase({pre[i], i});
}

bool check() {
    if(!pos.empty()) {
        if(e + sumNeg < *pos.rbegin()) return false;
    }
    if(!neg.empty()) {
        if(e + sumNeg - *neg.rbegin() < 0) return false;
    }
    return true;
}

void solve() {
    int n;
    cin >> n >> e;
    vector<int> a(n), b(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    for (int i = 0; i < n; ++i) {
        cin >> b[i];
    }

    pre.resize(n);
    for (int i = 0; i < n; ++i) {
        pre[i] = (i ? pre[i - 1] : 0) + b[i] - a[i];
    }

    int r = 0;
    ll ans = 0;

    for (int i = 0; i < n; ++i) {
        r = max(r, i);
        while (r < n) {
            add(a[r], b[r], r);
            if(check()) r ++;
            else {
                rem(a[r], b[r], r);
                break;
            }
        }
        ans += r - i - pres.order_of_key({i ? pre[i - 1] : 0, -1});
        if(r > i)
            rem(a[i], b[i], i);
    }
    cout << ans << endl;
}

signed main() {
    Drakon();
    int t = 1;
    //cin >> t;
    while (t--) {
        solve();
    }
}