#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include <algorithm>

#define SUBMIT 1

typedef long long ll;

#ifndef SUBMIT
static FILE *fr, *fw;

// Declaring variables
static int N;
static long long M;
static int* V;
static int B;
#endif

// Declaring functions
int quadri(int N, long long M, int* V) {
    int sol = N;

    int r = 0;
    ll current = 0;
    
    for (int p = 0; p < N; p++) {
        while (r < N && current + (ll)V[r] <= M) {
            current += (ll)V[r];
            r++;
        }

        sol = std::min(sol, r - p);

        if (r == N) break;

        current -= V[p];
    }

    return sol;
}

#ifndef SUBMIT
int main() {
    freopen("input.txt", "r", stdin);

	fr = stdin;
	fw = stdout;

	// Iterators used in for loops
	int i0;

	// Reading input
	fscanf(fr, "%d %lld", &N, &M);
	V = (int*)malloc(N * sizeof(int));
	for (i0 = 0; i0 < N; i0++) {
	    fscanf(fr, "%d", &V[i0]);
	}

	// Calling functions
	B = quadri(N, M, V);

	// Writing output
	fprintf(fw, "%d\n", B);
	
	fclose(fr);
	fclose(fw);
	return 0;
}
#endif
