#include<bits/stdc++.h>
#define N 2000000
#define ll long long
using namespace std;
ll a[N + 2];
ll S;
int n, ans = N + 2;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin>>n>>S;
    for(int i = 1; i<=n;i++)    cin>>a[i];
    int i = 1, j = 1;
    ll t = a[1];
    while(j <= n)
    {
        if(t < S) t+=a[++j];
        else
        {
            ans = min(ans, j - i + 1);
            t -= a[i++];
        }
    }
    if(ans == N + 2)    cout<<-1;
    else    cout<<ans;
}