#include using namespace std; using ll = long long; int N, H; int A[202020], B[202020]; ll S[202020], T[202020]; int main(void){ ios::sync_with_stdio(false); cin.tie(nullptr); cin >> N >> H; for(int i = 0;i < N;i++)cin >> A[i]; for(int i = 0;i < N;i++)cin >> B[i]; for(int i = 0;i < N;i++){ S[i + 1] = S[i] + (ll)(i + 1) * B[i]; T[i + 1] = T[i] + B[i]; } ll sum = 0, ans = 0; for(int l = 0, r = 0;l < N;){ while(r < N){ ll wr = S[r + 1] - l * T[r + 1]; ll wl = S[l] - l * T[l]; if(wr - wl > H)break; sum += A[r]; r++; } ans = max(ans, sum); sum -= A[l]; l++; } cout << ans << endl; return 0; }