#include <stdio.h>

static inline int min(int a, int b) { return (a <= b) ? a : b; }

int quadri(int N, long long M, int V[]) {
	// Scrivete qui la vostra soluzione
	//
	// valore massimo di B con somma V[i]..V[i+B] <= M
	int B = N;

	int runningSum = 0;

	int low, high = 0;
	for (low = 0; low < N; ++low) {
		while (runningSum + V[high] <= M && high < N) {
			runningSum += V[high++];
		}

		// printf("%d, %d\n", low, high);

		if (runningSum + V[high] > M)
			B = min(B, high - low);

		runningSum -= V[low];
	}

	return B;
}
