#include        "algorithm"
#include        "iostream"
#include        "numeric"
#include        "iomanip"
#include        "cstring"
#include        "math.h"
#include        "bitset"
#include        "string"
#include        "vector"
#include        "ctime"
#include        "queue"
#include        "stack"
#include        "map"
#include        "set"

#include        "ext/pb_ds/assoc_container.hpp" // Common file
#include        "ext/pb_ds/tree_policy.hpp" // Including tree_order_statistics_node_update
#include        "ext/pb_ds/detail/standard_policies.hpp"

using namespace std;
using namespace __gnu_pbds;

#define          f first
#define          lgn 25
#define          endl '\n'
#define          sc second
#define          N (int)2e5+5
#define          pb push_back
#define          mod 1000000007
#define          ld long double
#define          vi vector<int>
#define          eb emplace_back
#define          vpii vector<pii>
#define          mii map<int,int>
#define          int long long
#define          pii pair<int,int>
#define          pq priority_queue
#define          BLOCK (int)sqrt(N)
#define          test(x) while(x--)
#define          all(x) begin(x),end(x)
#define          allr(x) rbegin(x),rend(x)
#define          fo(i,a,n) for(int i=a;i<n;i++)
#define          rfo(i,n,a) for(int i=n;i>=a;i--)
#define          FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define          time() cerr << "Time : " << (double)clock() / (double)CLOCKS_PER_SEC << "s\n"
#define          PI acos(-1.0)
#define 		 bug(...)       __f (#__VA_ARGS__, __VA_ARGS__)

typedef tree< int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update >
OS ;

template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{
     const char* comma = strchr (names + 1, ',');
     cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}

inline void INP()
{
	#ifndef ONLINE_JUDGE
	    freopen("input.txt","r",stdin);
	    freopen("output.txt","w",stdout);
	#endif
}

const int inf = 0x3f3f3f3f;
const int INF = 0x3f3f3f3f3f3f3f3f;

int n,m,k,q;
string s;
vi adj[N];
int vis[N],par[N],a[N];

void go()
{
	cin >> n >> k;
	int sum = 0;
	int mx = 0;

	fo(i,0,n)
	{
		cin >> a[i];
		if( i != n-1 ) sum += a[i] , mx = max( mx , a[i] );
	}

	int x = a[n-1] + sum;
	int y = k - mx;

	int ans = min( { n , k - x + 1 , y} );

	if( ans <= 0 ) ans = -1;
	cout << ans << endl;

}

int32_t main()
{
	INP();
	FAST;
	int t=1;
	// cin>>t;
	test(t) go();
}


#include        "algorithm"
#include        "iostream"
#include        "numeric"
#include        "iomanip"
#include        "cstring"
#include        "math.h"
#include        "bitset"
#include        "string"
#include        "vector"
#include        "ctime"
#include        "queue"
#include        "stack"
#include        "map"
#include        "set"

#include        "ext/pb_ds/assoc_container.hpp" // Common file
#include        "ext/pb_ds/tree_policy.hpp" // Including tree_order_statistics_node_update
#include        "ext/pb_ds/detail/standard_policies.hpp"

using namespace std;
using namespace __gnu_pbds;

#define          f first
#define          lgn 25
#define          endl '\n'
#define          sc second
#define          N (int)2e5+5
#define          pb push_back
#define          mod 1000000007
#define          ld long double
#define          vi vector<int>
#define          eb emplace_back
#define          vpii vector<pii>
#define          mii map<int,int>
#define          int long long
#define          pii pair<int,int>
#define          pq priority_queue
#define          BLOCK (int)sqrt(N)
#define          test(x) while(x--)
#define          all(x) begin(x),end(x)
#define          allr(x) rbegin(x),rend(x)
#define          fo(i,a,n) for(int i=a;i<n;i++)
#define          rfo(i,n,a) for(int i=n;i>=a;i--)
#define          FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define          time() cerr << "Time : " << (double)clock() / (double)CLOCKS_PER_SEC << "s\n"
#define          PI acos(-1.0)
#define 		 bug(...)       __f (#__VA_ARGS__, __VA_ARGS__)

typedef tree< int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update >
OS ;

template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{
     const char* comma = strchr (names + 1, ',');
     cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}

inline void INP()
{
	#ifndef ONLINE_JUDGE
	    freopen("input.txt","r",stdin);
	    freopen("output.txt","w",stdout);
	#endif
}

const int inf = 0x3f3f3f3f;
const int INF = 0x3f3f3f3f3f3f3f3f;

int n,m,k,q;
string s;
vi adj[N];
int vis[N],pre[N],a[N];

void go()
{
	cin >> n >> k;
	int ok = 0;

	fo(i,1,n+1)
	{
		cin >> a[i];
		if( i == 1 and a[i] <= 0 ) ok = 1;
		pre[i] = pre[i-1] + a[i];
	}
	int ans = INF;
	fo(i,1,n+1)
	{
		ans = min( ans , k - pre[i] + 1 - ok);
	}

	if( ans > k or ans < 0 ) ans = 0;
	ans = min( ans , k );

	cout << ans << endl;

}

int32_t main()
{
	INP();
	FAST;
	int t=1;
	// cin>>t;
	test(t) go();
}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
// agr set ki tarah krna hai to less vrna agr multiset ki tarah to less_equal
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

long long int mod97 = 1000000007;
double pi = 3.1415926536;
bool comp(pair<long long int, long long int>a, pair<long long int, long long int>b)
{
    if (a.first == b.first)
    {
        if (a.second <= b.second)
            return true;
        else
            return false;
    }
    if (a.first > b.first)
        return true;
    else return false;
}
bool rev(long long int a, long long int b)
{
    if (a > b)return true;
    else return false;
}
bool compa(pair<string, pair<int, int>>a, pair<string, pair<int, int>>b)
{
    if (a.first == b.first)
    {
        if (a.second.first > b.second.first)
            return true;
        else
            return false;
    }
    if (a.first < b.first)
        return true;
    else
        return false;
}
long long int gcd(long long int bdda, long long int chota)
{
    if (chota == 0)
        return bdda;
    return gcd(chota, bdda % chota);
}
long long int lcm(long long int a, long long int b)
{
    return a * b / gcd(max(a, b), min(a, b));
}
long long int powerm(long long int a, long long int n, long long int modn)
{
    if (n == 0)return 1;
    if (n % 2 == 0)
    {
        long long int val = powerm(a, n / 2, mod97);
        val = (val * val) % modn; return val;
    }
    else
    {
        long long int val = powerm(a, n / 2, mod97);
        val = ((val * val) % modn * a) % modn; return val;
    }
}
long long int power(long long int a, long long int n)
{
    if (n == 0)return 1;
    if (n % 2 == 0)
    {
        long long int val = power(a, n / 2);
        val = (val * val); return val;
    }
    else
    {
        long long int val = power(a, n / 2);
        val = ((val * val) * a) ; return val;
    }
}

void solve()
{
    long long int n, w; cin >> n >> w; long long int a[n];
    long long int curr = 0, ma = INT_MIN, mi = INT_MAX;
    for (long long int i = 0; i < n; i++)
    {
        cin >> a[i];
        curr += a[i];
        ma = max(ma, curr);
        mi = min(mi, curr);
    }
    if (ma > w)
        cout << 0;
    else if (mi * (-1) > w)
        cout << 0;
    else if (mi < 0)cout << w + 1 + mi - ma;
    else cout << w - ma + 1;
}

int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r" , stdin);
    freopen("output.txt", "w", stdout);
#endif
    int t;
    t = 1;
    //cin >> t; //long long int count = 1;
    while (t--)
    {
        //cout << "Case #" << count << ": ";
        solve();
    }
}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
// agr set ki tarah krna hai to less vrna agr multiset ki tarah to less_equal
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

long long int mod97 = 1000000007;
double pi = 3.1415926536;
bool comp(pair<long long int, long long int>a, pair<long long int, long long int>b)
{
    if (a.first == b.first)
    {
        if (a.second <= b.second)
            return true;
        else
            return false;
    }
    if (a.first > b.first)
        return true;
    else return false;
}
bool rev(long long int a, long long int b)
{
    if (a > b)return true;
    else return false;
}
bool compa(pair<string, pair<int, int>>a, pair<string, pair<int, int>>b)
{
    if (a.first == b.first)
    {
        if (a.second.first > b.second.first)
            return true;
        else
            return false;
    }
    if (a.first < b.first)
        return true;
    else
        return false;
}
long long int gcd(long long int bdda, long long int chota)
{
    if (chota == 0)
        return bdda;
    return gcd(chota, bdda % chota);
}
long long int lcm(long long int a, long long int b)
{
    return a * b / gcd(max(a, b), min(a, b));
}
long long int powerm(long long int a, long long int n, long long int modn)
{
    if (n == 0)return 1;
    if (n % 2 == 0)
    {
        long long int val = powerm(a, n / 2, mod97);
        val = (val * val) % modn; return val;
    }
    else
    {
        long long int val = powerm(a, n / 2, mod97);
        val = ((val * val) % modn * a) % modn; return val;
    }
}
long long int power(long long int a, long long int n)
{
    if (n == 0)return 1;
    if (n % 2 == 0)
    {
        long long int val = power(a, n / 2);
        val = (val * val); return val;
    }
    else
    {
        long long int val = power(a, n / 2);
        val = ((val * val) * a) ; return val;
    }
}

void solve()
{
    long long int n, w; cin >> n >> w; long long int a[n];
    long long int curr = 0, ma = INT_MIN;
    for (long long int i = 0; i < n; i++)
    {
        cin >> a[i];
        curr += a[i];
        ma = max(ma, curr);
    }
    if (ma > w)
        cout << 0;
    else cout << min( w - ma + 1, w);
}

int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r" , stdin);
    freopen("output.txt", "w", stdout);
#endif
    int t;
    t = 1;
    //cin >> t; //long long int count = 1;
    while (t--)
    {
        //cout << "Case #" << count << ": ";
        solve();
    }
}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
// agr set ki tarah krna hai to less vrna agr multiset ki tarah to less_equal
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

long long int mod97 = 1000000007;
double pi = 3.1415926536;
bool comp(pair<long long int, long long int>a, pair<long long int, long long int>b)
{
    if (a.first == b.first)
    {
        if (a.second <= b.second)
            return true;
        else
            return false;
    }
    if (a.first > b.first)
        return true;
    else return false;
}
bool rev(long long int a, long long int b)
{
    if (a > b)return true;
    else return false;
}
bool compa(pair<string, pair<int, int>>a, pair<string, pair<int, int>>b)
{
    if (a.first == b.first)
    {
        if (a.second.first > b.second.first)
            return true;
        else
            return false;
    }
    if (a.first < b.first)
        return true;
    else
        return false;
}
long long int gcd(long long int bdda, long long int chota)
{
    if (chota == 0)
        return bdda;
    return gcd(chota, bdda % chota);
}
long long int lcm(long long int a, long long int b)
{
    return a * b / gcd(max(a, b), min(a, b));
}
long long int powerm(long long int a, long long int n, long long int modn)
{
    if (n == 0)return 1;
    if (n % 2 == 0)
    {
        long long int val = powerm(a, n / 2, mod97);
        val = (val * val) % modn; return val;
    }
    else
    {
        long long int val = powerm(a, n / 2, mod97);
        val = ((val * val) % modn * a) % modn; return val;
    }
}
long long int power(long long int a, long long int n)
{
    if (n == 0)return 1;
    if (n % 2 == 0)
    {
        long long int val = power(a, n / 2);
        val = (val * val); return val;
    }
    else
    {
        long long int val = power(a, n / 2);
        val = ((val * val) * a) ; return val;
    }
}

void solve()
{
    long long int n, w; cin >> n >> w; long long int a[n];
    long long int curr = 0, ma = INT_MIN, mi = INT_MAX;
    for (long long int i = 0; i < n; i++)
    {
        cin >> a[i];
        curr += a[i];
        ma = max(ma, curr);
        mi = min(mi, curr);
    }
    if (ma > w)
        cout << 0;
    else if (mi * (-1) > w)
        cout << 0;
    else if (mi  <= 0 && ma >= 0)cout << w + 1 + mi - ma;
    else if (ma < 0)cout << w + mi + 1;
    else if (mi > 0)cout << w - ma + 1;
}

int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r" , stdin);
    freopen("output.txt", "w", stdout);
#endif
    int t;
    t = 1;
    //cin >> t; //long long int count = 1;
    while (t--)
    {
        //cout << "Case #" << count << ": ";
        solve();
    }
}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
// agr set ki tarah krna hai to less vrna agr multiset ki tarah to less_equal
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

long long int mod97 = 1000000007;
double pi = 3.1415926536;
bool comp(pair<long long int, long long int>a, pair<long long int, long long int>b)
{
    if (a.first == b.first)
    {
        if (a.second <= b.second)
            return true;
        else
            return false;
    }
    if (a.first > b.first)
        return true;
    else return false;
}
bool rev(long long int a, long long int b)
{
    if (a > b)return true;
    else return false;
}
bool compa(pair<string, pair<int, int>>a, pair<string, pair<int, int>>b)
{
    if (a.first == b.first)
    {
        if (a.second.first > b.second.first)
            return true;
        else
            return false;
    }
    if (a.first < b.first)
        return true;
    else
        return false;
}
long long int gcd(long long int bdda, long long int chota)
{
    if (chota == 0)
        return bdda;
    return gcd(chota, bdda % chota);
}
long long int lcm(long long int a, long long int b)
{
    return a * b / gcd(max(a, b), min(a, b));
}
long long int powerm(long long int a, long long int n, long long int modn)
{
    if (n == 0)return 1;
    if (n % 2 == 0)
    {
        long long int val = powerm(a, n / 2, mod97);
        val = (val * val) % modn; return val;
    }
    else
    {
        long long int val = powerm(a, n / 2, mod97);
        val = ((val * val) % modn * a) % modn; return val;
    }
}
long long int power(long long int a, long long int n)
{
    if (n == 0)return 1;
    if (n % 2 == 0)
    {
        long long int val = power(a, n / 2);
        val = (val * val); return val;
    }
    else
    {
        long long int val = power(a, n / 2);
        val = ((val * val) * a) ; return val;
    }
}

void solve()
{
    long long int n, w; cin >> n >> w; long long int a[n];
    long long int curr = 0, ma = INT_MIN, mi = INT_MAX;
    for (long long int i = 0; i < n; i++)
    {
        cin >> a[i];
        curr += a[i];
        ma = max(ma, curr);
        mi = min(mi, curr);
    }
    if (ma > w)
        cout << 0;
    else if (mi * (-1) > w)
        cout << 0;
    else if (mi  <= 0 && ma >= 0)cout << max(0ll, w + 1 + mi - ma);
    else if (ma < 0)cout << max(0ll, w + mi + 1);
    else if (mi > 0)cout << max(0ll, w - ma + 1);
}

int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r" , stdin);
    freopen("output.txt", "w", stdout);
#endif
    int t;
    t = 1;
    //cin >> t; //long long int count = 1;
    while (t--)
    {
        //cout << "Case #" << count << ": ";
        solve();
    }
}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
// agr set ki tarah krna hai to less vrna agr multiset ki tarah to less_equal
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

long long int mod97 = 1000000007;
double pi = 3.1415926536;
bool comp(pair<long long int, long long int>a, pair<long long int, long long int>b)
{
    if (a.first == b.first)
    {
        if (a.second <= b.second)
            return true;
        else
            return false;
    }
    if (a.first > b.first)
        return true;
    else return false;
}
bool rev(long long int a, long long int b)
{
    if (a > b)return true;
    else return false;
}
bool compa(pair<string, pair<int, int>>a, pair<string, pair<int, int>>b)
{
    if (a.first == b.first)
    {
        if (a.second.first > b.second.first)
            return true;
        else
            return false;
    }
    if (a.first < b.first)
        return true;
    else
        return false;
}
long long int gcd(long long int bdda, long long int chota)
{
    if (chota == 0)
        return bdda;
    return gcd(chota, bdda % chota);
}
long long int lcm(long long int a, long long int b)
{
    return a * b / gcd(max(a, b), min(a, b));
}
long long int powerm(long long int a, long long int n, long long int modn)
{
    if (n == 0)return 1;
    if (n % 2 == 0)
    {
        long long int val = powerm(a, n / 2, mod97);
        val = (val * val) % modn; return val;
    }
    else
    {
        long long int val = powerm(a, n / 2, mod97);
        val = ((val * val) % modn * a) % modn; return val;
    }
}
long long int power(long long int a, long long int n)
{
    if (n == 0)return 1;
    if (n % 2 == 0)
    {
        long long int val = power(a, n / 2);
        val = (val * val); return val;
    }
    else
    {
        long long int val = power(a, n / 2);
        val = ((val * val) * a) ; return val;
    }
}

void solve()
{
    long long int n, w; cin >> n >> w; long long int a[n];
    long long int curr = 0, ma = INT_MIN, mi = INT_MAX;
    for (long long int i = 0; i < n; i++)
    {
        cin >> a[i];
        curr += a[i];
        ma = max(ma, curr);
        mi = min(mi, curr);
    }
    if (ma > w)
        cout << 0;
    else if (mi < 0)cout << w + 1 + mi - ma;
    else cout << w - ma + 1;
}

int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r" , stdin);
    freopen("output.txt", "w", stdout);
#endif
    int t;
    t = 1;
    //cin >> t; //long long int count = 1;
    while (t--)
    {
        //cout << "Case #" << count << ": ";
        solve();
    }
}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
// agr set ki tarah krna hai to less vrna agr multiset ki tarah to less_equal
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

long long int mod97 = 1000000007;
double pi = 3.1415926536;
bool comp(pair<long long int, long long int>a, pair<long long int, long long int>b)
{
    if (a.first == b.first)
    {
        if (a.second <= b.second)
            return true;
        else
            return false;
    }
    if (a.first > b.first)
        return true;
    else return false;
}
bool rev(long long int a, long long int b)
{
    if (a > b)return true;
    else return false;
}
bool compa(pair<string, pair<int, int>>a, pair<string, pair<int, int>>b)
{
    if (a.first == b.first)
    {
        if (a.second.first > b.second.first)
            return true;
        else
            return false;
    }
    if (a.first < b.first)
        return true;
    else
        return false;
}
long long int gcd(long long int bdda, long long int chota)
{
    if (chota == 0)
        return bdda;
    return gcd(chota, bdda % chota);
}
long long int lcm(long long int a, long long int b)
{
    return a * b / gcd(max(a, b), min(a, b));
}
long long int powerm(long long int a, long long int n, long long int modn)
{
    if (n == 0)return 1;
    if (n % 2 == 0)
    {
        long long int val = powerm(a, n / 2, mod97);
        val = (val * val) % modn; return val;
    }
    else
    {
        long long int val = powerm(a, n / 2, mod97);
        val = ((val * val) % modn * a) % modn; return val;
    }
}
long long int power(long long int a, long long int n)
{
    if (n == 0)return 1;
    if (n % 2 == 0)
    {
        long long int val = power(a, n / 2);
        val = (val * val); return val;
    }
    else
    {
        long long int val = power(a, n / 2);
        val = ((val * val) * a) ; return val;
    }
}

void solve()
{
    long long int n, w; cin >> n >> w; long long int a[n];
    long long int curr = 0, ma = INT_MIN, mi = INT_MAX;
    for (long long int i = 0; i < n; i++)
    {
        cin >> a[i];
        curr += a[i];
        ma = max(ma, curr);
        mi = min(mi, curr);
    }
    if (ma > w)
        cout << 0;
    else if (mi * (-1) > w)
        cout << 0;
    else if (mi < 0 && ma > 0)cout << w + 1 + mi - ma;
    else if (ma < 0)cout << w + mi + 1;
    else if (mi > 0)cout << w - ma + 1;
}

int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r" , stdin);
    freopen("output.txt", "w", stdout);
#endif
    int t;
    t = 1;
    //cin >> t; //long long int count = 1;
    while (t--)
    {
        //cout << "Case #" << count << ": ";
        solve();
    }
}


#include <bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;

//methods: find_by_order(k); & order_of_key(k);
//To make it an ordered_multiset, use pairs of (value, time_of_insertion)
//to distinguish values which are similar

#define int long long
#define pii pair<int,int>
#define pb push_back
template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
            os << "{";
                for(auto it = v.begin(); it != v.end(); ++it) {
                                if( it != v.begin() ) os << ", ";
                                        os << *it;
                                            }
                    return os << "}";

}
#define vi vector<int>
#define ed end()
#define bg begin()
template < typename F, typename S >
ostream& operator << ( ostream& os, const pair< F, S > & p ) {
            return os << "(" << p.first << ", " << p.second << ")";
}
#define sz size()

template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
            os << "[";
                for(auto it = v.begin(); it != v.end(); ++it) {
                                if( it != v.begin() ) os << ", ";
                                        os << *it;
                                            }
                    return os << "]";
}
#define ln length()
#define all(x) x.begin(),x.end()
#define endl "\n"
#define NL cout<<'\n';
#define F first
#define S second
template < typename T >
ostream &operator << ( ostream & os, const multiset< T > &v ) {
            os << "[";
                for(auto it = v.begin(); it != v.end(); ++it) {
                                if( it != v.begin() ) os << ", ";
                                        os << *it;
                                            }
                    return os << "]";
}
#define disp(x) for(auto t : x )cout<<t<<" ";
#define for0(n) for(int i=0;i<n;i++)
#define for0j(n) for(int j=0;j<n;j++)
#define SS <<" "<<
#define arrin(a,n) vi a(n);for0(n){cin>>a[i];}
#define pf(x) cout<<x<<endl;
#define Check pf("Check")
#define gridin(num,n,m) for0(n){for0j(m) cin>>num[i][j];}
#define dispgrid(num,n,m) for0(n){for0j(m) cout<<num[i][j]<<" "; cout<<endl;}
template < typename F, typename S >
ostream &operator << ( ostream & os, const map< F, S > &v ) {
            os << "[";
                for(auto it = v.begin(); it != v.end(); ++it) {
                                if( it != v.begin() ) os << ", ";
                                        os << it -> first << " = " << it -> second ;
                                            }
                    return os << "]";
}
#define tkst(x) string x;cin >> x;
#define tk(a) int a;cin>>a;
#define tk2(a,b)tk(a)tk(b)
#define tk3(a,b,c)tk2(a,b)tk(c)
#define tk4(a,b,c,d)tk2(a,b)tk2(c,d)
#define tk5(a,b,c,d,e)tk4(a,b,c,d)tk(e)
#define tk6(a,b,c,d,e,f)tk3(a,b,c)tk3(d,e,f)
#define tk7(a,b,c,d,e,f,g)tk6(a,b,c,d,e,f)tk(g)
#define tk8(a,b,c,d,e,f,g,h)tk7(a,b,c,d,e,f,g)tk(h)
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vpii vector<pii>
#define acum accumulate
#define fmap gp_hash_table
#define LONG LLONG
const int MOD=1000000007;
const int N=100000;

vector<string> vec_splitter(string s) {
	s += ',';
	vector<string> res;
	while(!s.empty()) {
		res.push_back(s.substr(0, s.find(',')));
		s = s.substr(s.find(',') + 1);
	}
	return res;
}

void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx,
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
	if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") =  ";
	stringstream ss; ss << H;
	cerr << args[idx] << " = " << ss.str();
	debug_out(args, idx + 1, LINE_NUM, T...);
}

#ifndef ONLINE_JUDGE
#define db(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#endif

// To find number of elements less than k in array a
// answer would be int res = upper_bound(all(a),k) - a.bg

// To find number of elements greater than k in array a
// answer would be int res = a.ed - upper_bound(all(a),k)

int bruteForce(int n,int w,vi &a){
	int pref[n];
	pref[0]=a[0];
	for(int i=1;i<n;i++){
		pref[i]=pref[i-1]+a[i];
	}
	int res=0;
	// 2 3 0
	for(int i=0;i<=w;i++){
		vi temp;
		for(int j=0;j<n;j++){
			temp.pb(i+pref[j]);
		}
		bool hoga=true;
		for(int j=0;j<n;j++){
			if(temp[j]<0 || temp[j]>w){
				hoga=false;
				break;
			}
		}
		if(hoga)res++;
	}
	return res;
}

int fast_solve(int n,int w,vi &a){
	int pref[n];
	pref[0]=a[0];
	for(int i=1;i<n;i++){
		pref[i]=pref[i-1]+a[i];
	}
	// 2 3 0
//	Check
	//disp(pref)NL
	int mini = *min_element(pref,pref+n);
	int maxi = *max_element(pref,pref+n);

	int pos1 =max(0LL,-mini);
	for0(n){
		pref[i]+=pos1;
	}

	maxi = *max_element(pref,pref+n);
	if(maxi>=w)return 0;
//	disp(pref)NL

	return w-maxi+1;
}

int32_t main(){
	ios_base::sync_with_stdio(false);cin.tie(0);
	tk2(n,w)
	arrin(a,n)
	pf( fast_solve(n,w,a))
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;

//methods: find_by_order(k); & order_of_key(k);
//To make it an ordered_multiset, use pairs of (value, time_of_insertion)
//to distinguish values which are similar

#define int long long
#define pii pair<int,int>
#define pb push_back
template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
            os << "{";
                for(auto it = v.begin(); it != v.end(); ++it) {
                                if( it != v.begin() ) os << ", ";
                                        os << *it;
                                            }
                    return os << "}";

}
#define vi vector<int>
#define ed end()
#define bg begin()
template < typename F, typename S >
ostream& operator << ( ostream& os, const pair< F, S > & p ) {
            return os << "(" << p.first << ", " << p.second << ")";
}
#define sz size()

template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
            os << "[";
                for(auto it = v.begin(); it != v.end(); ++it) {
                                if( it != v.begin() ) os << ", ";
                                        os << *it;
                                            }
                    return os << "]";
}
#define ln length()
#define all(x) x.begin(),x.end()
#define endl "\n"
#define NL cout<<'\n';
#define F first
#define S second
template < typename T >
ostream &operator << ( ostream & os, const multiset< T > &v ) {
            os << "[";
                for(auto it = v.begin(); it != v.end(); ++it) {
                                if( it != v.begin() ) os << ", ";
                                        os << *it;
                                            }
                    return os << "]";
}
#define disp(x) for(auto t : x )cout<<t<<" ";
#define for0(n) for(int i=0;i<n;i++)
#define for0j(n) for(int j=0;j<n;j++)
#define SS <<" "<<
#define arrin(a,n) vi a(n);for0(n){cin>>a[i];}
#define pf(x) cout<<x<<endl;
#define Check pf("Check")
#define gridin(num,n,m) for0(n){for0j(m) cin>>num[i][j];}
#define dispgrid(num,n,m) for0(n){for0j(m) cout<<num[i][j]<<" "; cout<<endl;}
template < typename F, typename S >
ostream &operator << ( ostream & os, const map< F, S > &v ) {
            os << "[";
                for(auto it = v.begin(); it != v.end(); ++it) {
                                if( it != v.begin() ) os << ", ";
                                        os << it -> first << " = " << it -> second ;
                                            }
                    return os << "]";
}
#define tkst(x) string x;cin >> x;
#define tk(a) int a;cin>>a;
#define tk2(a,b)tk(a)tk(b)
#define tk3(a,b,c)tk2(a,b)tk(c)
#define tk4(a,b,c,d)tk2(a,b)tk2(c,d)
#define tk5(a,b,c,d,e)tk4(a,b,c,d)tk(e)
#define tk6(a,b,c,d,e,f)tk3(a,b,c)tk3(d,e,f)
#define tk7(a,b,c,d,e,f,g)tk6(a,b,c,d,e,f)tk(g)
#define tk8(a,b,c,d,e,f,g,h)tk7(a,b,c,d,e,f,g)tk(h)
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vpii vector<pii>
#define acum accumulate
#define fmap gp_hash_table
#define LONG LLONG
const int MOD=1000000007;
const int N=100000;

vector<string> vec_splitter(string s) {
	s += ',';
	vector<string> res;
	while(!s.empty()) {
		res.push_back(s.substr(0, s.find(',')));
		s = s.substr(s.find(',') + 1);
	}
	return res;
}

void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx,
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
	if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") =  ";
	stringstream ss; ss << H;
	cerr << args[idx] << " = " << ss.str();
	debug_out(args, idx + 1, LINE_NUM, T...);
}

#ifndef ONLINE_JUDGE
#define db(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#endif

// To find number of elements less than k in array a
// answer would be int res = upper_bound(all(a),k) - a.bg

// To find number of elements greater than k in array a
// answer would be int res = a.ed - upper_bound(all(a),k)

int bruteForce(int n,int w,vi &a){
	int pref[n];
	pref[0]=a[0];
	for(int i=1;i<n;i++){
		pref[i]=pref[i-1]+a[i];
	}
	int res=0;
	// 2 3 0
	for(int i=0;i<=w;i++){
		vi temp;
		for(int j=0;j<n;j++){
			temp.pb(i+pref[j]);
		}
		bool hoga=true;
		for(int j=0;j<n;j++){
			if(temp[j]<0 || temp[j]>w){
				hoga=false;
				break;
			}
		}
		if(hoga)res++;
	}
	return res;
}

int fast_solve(int n,int w,vi &a){
	int pref[n];
	pref[0]=a[0];
	for(int i=1;i<n;i++){
		pref[i]=pref[i-1]+a[i];
	}
	int res=0;
	// 2 3 0
//	Check
	//disp(pref)NL
	int mini = *min_element(pref,pref+n);
	int maxi = *max_element(pref,pref+n);
	if(maxi>w)return 0;
	int pos1 =max(0LL,-mini);
	int pos2 = w-maxi;
//	pf("CD " SS pos1 SS pos2)
	return max(0LL,pos2-pos1+1);
}
vector<int> generateArray(int n){
	srand(time(NULL));
	vector<int> res;
	int elem_size=100;
	for(int i=0;i<n;i++){
		res.push_back(rand()%elem_size+1*(rand()%2==0?-1:1));
	}
	return res;
}

int32_t main(){
	ios_base::sync_with_stdio(false);cin.tie(0);
	tk2(n,w)
	arrin(a,n)
	if(w<=10000){
		pf(bruteForce(n,w,a))
	}else{
		pf(fast_solve(n,w,a))
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;

//methods: find_by_order(k); & order_of_key(k);
//To make it an ordered_multiset, use pairs of (value, time_of_insertion)
//to distinguish values which are similar

#define int long long
#define pii pair<int,int>
#define pb push_back
template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
            os << "{";
                for(auto it = v.begin(); it != v.end(); ++it) {
                                if( it != v.begin() ) os << ", ";
                                        os << *it;
                                            }
                    return os << "}";

}
#define vi vector<int>
#define ed end()
#define bg begin()
template < typename F, typename S >
ostream& operator << ( ostream& os, const pair< F, S > & p ) {
            return os << "(" << p.first << ", " << p.second << ")";
}
#define sz size()

template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
            os << "[";
                for(auto it = v.begin(); it != v.end(); ++it) {
                                if( it != v.begin() ) os << ", ";
                                        os << *it;
                                            }
                    return os << "]";
}
#define ln length()
#define all(x) x.begin(),x.end()
#define endl "\n"
#define NL cout<<'\n';
#define F first
#define S second
template < typename T >
ostream &operator << ( ostream & os, const multiset< T > &v ) {
            os << "[";
                for(auto it = v.begin(); it != v.end(); ++it) {
                                if( it != v.begin() ) os << ", ";
                                        os << *it;
                                            }
                    return os << "]";
}
#define disp(x) for(auto t : x )cout<<t<<" ";
#define for0(n) for(int i=0;i<n;i++)
#define for0j(n) for(int j=0;j<n;j++)
#define SS <<" "<<
#define arrin(a,n) vi a(n);for0(n){cin>>a[i];}
#define pf(x) cout<<x<<endl;
#define Check pf("Check")
#define gridin(num,n,m) for0(n){for0j(m) cin>>num[i][j];}
#define dispgrid(num,n,m) for0(n){for0j(m) cout<<num[i][j]<<" "; cout<<endl;}
template < typename F, typename S >
ostream &operator << ( ostream & os, const map< F, S > &v ) {
            os << "[";
                for(auto it = v.begin(); it != v.end(); ++it) {
                                if( it != v.begin() ) os << ", ";
                                        os << it -> first << " = " << it -> second ;
                                            }
                    return os << "]";
}
#define tkst(x) string x;cin >> x;
#define tk(a) int a;cin>>a;
#define tk2(a,b)tk(a)tk(b)
#define tk3(a,b,c)tk2(a,b)tk(c)
#define tk4(a,b,c,d)tk2(a,b)tk2(c,d)
#define tk5(a,b,c,d,e)tk4(a,b,c,d)tk(e)
#define tk6(a,b,c,d,e,f)tk3(a,b,c)tk3(d,e,f)
#define tk7(a,b,c,d,e,f,g)tk6(a,b,c,d,e,f)tk(g)
#define tk8(a,b,c,d,e,f,g,h)tk7(a,b,c,d,e,f,g)tk(h)
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vpii vector<pii>
#define acum accumulate
#define fmap gp_hash_table
#define LONG LLONG
const int MOD=1000000007;
const int N=100000;

vector<string> vec_splitter(string s) {
	s += ',';
	vector<string> res;
	while(!s.empty()) {
		res.push_back(s.substr(0, s.find(',')));
		s = s.substr(s.find(',') + 1);
	}
	return res;
}

void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx,
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
	if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") =  ";
	stringstream ss; ss << H;
	cerr << args[idx] << " = " << ss.str();
	debug_out(args, idx + 1, LINE_NUM, T...);
}

#ifndef ONLINE_JUDGE
#define db(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#endif

// To find number of elements less than k in array a
// answer would be int res = upper_bound(all(a),k) - a.bg

// To find number of elements greater than k in array a
// answer would be int res = a.ed - upper_bound(all(a),k)

int bruteForce(int n,int w,vi &a){
	int pref[n];
	pref[0]=a[0];
	for(int i=1;i<n;i++){
		pref[i]=pref[i-1]+a[i];
	}
	int res=0;
	// 2 3 0
	for(int i=0;i<=w;i++){
		vi temp;
		for(int j=0;j<n;j++){
			temp.pb(i+pref[j]);
		}
		bool hoga=true;
		for(int j=0;j<n;j++){
			if(temp[j]<0 || temp[j]>w){
				hoga=false;
				break;
			}
		}
		if(hoga)res++;
	}
	return res;
}

int fast_solve(int n,int w,vi &a){
	int pref[n];
	pref[0]=a[0];
	for(int i=1;i<n;i++){
		pref[i]=pref[i-1]+a[i];
	}
	int res=0;
	// 2 3 0
//	Check
	//disp(pref)NL
	int mini = *min_element(pref,pref+n);
	int maxi = *max_element(pref,pref+n);
	if(maxi>w)return 0;
	int pos1 =max(0LL,-mini);
	int pos2 = w-maxi;
//	pf("CD " SS pos1 SS pos2)
	return pos2-pos1+1;
}

int32_t main(){
	ios_base::sync_with_stdio(false);cin.tie(0);

		tk2(n,w)
		arrin(a,n)
		cout << fast_solve(n,w,a) << endl;

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;

//methods: find_by_order(k); & order_of_key(k);
//To make it an ordered_multiset, use pairs of (value, time_of_insertion)
//to distinguish values which are similar

#define int long long
#define pii pair<int,int>
#define pb push_back
template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
            os << "{";
                for(auto it = v.begin(); it != v.end(); ++it) {
                                if( it != v.begin() ) os << ", ";
                                        os << *it;
                                            }
                    return os << "}";

}
#define vi vector<int>
#define ed end()
#define bg begin()
template < typename F, typename S >
ostream& operator << ( ostream& os, const pair< F, S > & p ) {
            return os << "(" << p.first << ", " << p.second << ")";
}
#define sz size()

template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
            os << "[";
                for(auto it = v.begin(); it != v.end(); ++it) {
                                if( it != v.begin() ) os << ", ";
                                        os << *it;
                                            }
                    return os << "]";
}
#define ln length()
#define all(x) x.begin(),x.end()
#define endl "\n"
#define NL cout<<'\n';
#define F first
#define S second
template < typename T >
ostream &operator << ( ostream & os, const multiset< T > &v ) {
            os << "[";
                for(auto it = v.begin(); it != v.end(); ++it) {
                                if( it != v.begin() ) os << ", ";
                                        os << *it;
                                            }
                    return os << "]";
}
#define disp(x) for(auto t : x )cout<<t<<" ";
#define for0(n) for(int i=0;i<n;i++)
#define for0j(n) for(int j=0;j<n;j++)
#define SS <<" "<<
#define arrin(a,n) vi a(n);for0(n){cin>>a[i];}
#define pf(x) cout<<x<<endl;
#define Check pf("Check")
#define gridin(num,n,m) for0(n){for0j(m) cin>>num[i][j];}
#define dispgrid(num,n,m) for0(n){for0j(m) cout<<num[i][j]<<" "; cout<<endl;}
template < typename F, typename S >
ostream &operator << ( ostream & os, const map< F, S > &v ) {
            os << "[";
                for(auto it = v.begin(); it != v.end(); ++it) {
                                if( it != v.begin() ) os << ", ";
                                        os << it -> first << " = " << it -> second ;
                                            }
                    return os << "]";
}
#define tkst(x) string x;cin >> x;
#define tk(a) int a;cin>>a;
#define tk2(a,b)tk(a)tk(b)
#define tk3(a,b,c)tk2(a,b)tk(c)
#define tk4(a,b,c,d)tk2(a,b)tk2(c,d)
#define tk5(a,b,c,d,e)tk4(a,b,c,d)tk(e)
#define tk6(a,b,c,d,e,f)tk3(a,b,c)tk3(d,e,f)
#define tk7(a,b,c,d,e,f,g)tk6(a,b,c,d,e,f)tk(g)
#define tk8(a,b,c,d,e,f,g,h)tk7(a,b,c,d,e,f,g)tk(h)
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vpii vector<pii>
#define acum accumulate
#define fmap gp_hash_table
#define LONG LLONG
const int MOD=1000000007;
const int N=100000;

vector<string> vec_splitter(string s) {
	s += ',';
	vector<string> res;
	while(!s.empty()) {
		res.push_back(s.substr(0, s.find(',')));
		s = s.substr(s.find(',') + 1);
	}
	return res;
}

void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx,
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
	if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") =  ";
	stringstream ss; ss << H;
	cerr << args[idx] << " = " << ss.str();
	debug_out(args, idx + 1, LINE_NUM, T...);
}

#ifndef ONLINE_JUDGE
#define db(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#endif

// To find number of elements less than k in array a
// answer would be int res = upper_bound(all(a),k) - a.bg

// To find number of elements greater than k in array a
// answer would be int res = a.ed - upper_bound(all(a),k)

int32_t main(){
	ios_base::sync_with_stdio(false);cin.tie(0);
	tk2(n,w)
	arrin(a,n)
	int pref[n];
	pref[0]=a[0];
	for(int i=1;i<n;i++){
		pref[i]=pref[i-1]+a[i];
	}
//	disp(pref)NL
	int mini=*min_element(pref,pref+n);
	int maxi=*max_element(pref,pref+n);
	int l=-mini;
	if(l<0)l=0;
	if(maxi>w){
		pf(0)
		return 0;
	}
	int r=w-maxi;
	pf(r+1-l)
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;

//methods: find_by_order(k); & order_of_key(k);
//To make it an ordered_multiset, use pairs of (value, time_of_insertion)
//to distinguish values which are similar

#define int long long
#define pii pair<int,int>
#define pb push_back
template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
            os << "{";
                for(auto it = v.begin(); it != v.end(); ++it) {
                                if( it != v.begin() ) os << ", ";
                                        os << *it;
                                            }
                    return os << "}";

}
#define vi vector<int>
#define ed end()
#define bg begin()
template < typename F, typename S >
ostream& operator << ( ostream& os, const pair< F, S > & p ) {
            return os << "(" << p.first << ", " << p.second << ")";
}
#define sz size()

template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
            os << "[";
                for(auto it = v.begin(); it != v.end(); ++it) {
                                if( it != v.begin() ) os << ", ";
                                        os << *it;
                                            }
                    return os << "]";
}
#define ln length()
#define all(x) x.begin(),x.end()
#define endl "\n"
#define NL cout<<'\n';
#define F first
#define S second
template < typename T >
ostream &operator << ( ostream & os, const multiset< T > &v ) {
            os << "[";
                for(auto it = v.begin(); it != v.end(); ++it) {
                                if( it != v.begin() ) os << ", ";
                                        os << *it;
                                            }
                    return os << "]";
}
#define disp(x) for(auto t : x )cout<<t<<" ";
#define for0(n) for(int i=0;i<n;i++)
#define for0j(n) for(int j=0;j<n;j++)
#define SS <<" "<<
#define arrin(a,n) vi a(n);for0(n){cin>>a[i];}
#define pf(x) cout<<x<<endl;
#define Check pf("Check")
#define gridin(num,n,m) for0(n){for0j(m) cin>>num[i][j];}
#define dispgrid(num,n,m) for0(n){for0j(m) cout<<num[i][j]<<" "; cout<<endl;}
template < typename F, typename S >
ostream &operator << ( ostream & os, const map< F, S > &v ) {
            os << "[";
                for(auto it = v.begin(); it != v.end(); ++it) {
                                if( it != v.begin() ) os << ", ";
                                        os << it -> first << " = " << it -> second ;
                                            }
                    return os << "]";
}
#define tkst(x) string x;cin >> x;
#define tk(a) int a;cin>>a;
#define tk2(a,b)tk(a)tk(b)
#define tk3(a,b,c)tk2(a,b)tk(c)
#define tk4(a,b,c,d)tk2(a,b)tk2(c,d)
#define tk5(a,b,c,d,e)tk4(a,b,c,d)tk(e)
#define tk6(a,b,c,d,e,f)tk3(a,b,c)tk3(d,e,f)
#define tk7(a,b,c,d,e,f,g)tk6(a,b,c,d,e,f)tk(g)
#define tk8(a,b,c,d,e,f,g,h)tk7(a,b,c,d,e,f,g)tk(h)
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vpii vector<pii>
#define acum accumulate
#define fmap gp_hash_table
#define LONG LLONG
const int MOD=1000000007;
const int N=100000;

vector<string> vec_splitter(string s) {
	s += ',';
	vector<string> res;
	while(!s.empty()) {
		res.push_back(s.substr(0, s.find(',')));
		s = s.substr(s.find(',') + 1);
	}
	return res;
}

void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx,
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
	if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") =  ";
	stringstream ss; ss << H;
	cerr << args[idx] << " = " << ss.str();
	debug_out(args, idx + 1, LINE_NUM, T...);
}

#ifndef ONLINE_JUDGE
#define db(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#endif

// To find number of elements less than k in array a
// answer would be int res = upper_bound(all(a),k) - a.bg

// To find number of elements greater than k in array a
// answer would be int res = a.ed - upper_bound(all(a),k)

int bruteForce(int n,int w,vi &a){
	int pref[n];
	pref[0]=a[0];
	for(int i=1;i<n;i++){
		pref[i]=pref[i-1]+a[i];
	}
	int res=0;
	// 2 3 0
	for(int i=0;i<=w;i++){
		vi temp;
		for(int j=0;j<n;j++){
			temp.pb(i+pref[j]);
		}
		bool hoga=true;
		for(int j=0;j<n;j++){
			if(temp[j]<0 || temp[j]>w){
				hoga=false;
				break;
			}
		}
		if(hoga)res++;
	}
	return res;
}

int fast_solve(int n,int w,vi &a){
	int pref[n];
	pref[0]=a[0];
	for(int i=1;i<n;i++){
		pref[i]=pref[i-1]+a[i];
	}
	int res=0;
	// 2 3 0
//	Check
	//disp(pref)NL
	int mini = *min_element(pref,pref+n);
	int maxi = *max_element(pref,pref+n);

	if(maxi>w)return 0;
	int pos1 =max(0LL,-mini);
	int pos2 = w-maxi;
	//pf("CD " SS pos1 SS pos2)
	return max(0LL,pos2-pos1+1);
}

int32_t main(){
	ios_base::sync_with_stdio(false);cin.tie(0);
	tk2(n,w)
	arrin(a,n)
	pf( fast_solve(n,w,a))
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;

//methods: find_by_order(k); & order_of_key(k);
//To make it an ordered_multiset, use pairs of (value, time_of_insertion)
//to distinguish values which are similar

#define int long long
#define pii pair<int,int>
#define pb push_back
template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
            os << "{";
                for(auto it = v.begin(); it != v.end(); ++it) {
                                if( it != v.begin() ) os << ", ";
                                        os << *it;
                                            }
                    return os << "}";

}
#define vi vector<int>
#define ed end()
#define bg begin()
template < typename F, typename S >
ostream& operator << ( ostream& os, const pair< F, S > & p ) {
            return os << "(" << p.first << ", " << p.second << ")";
}
#define sz size()

template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
            os << "[";
                for(auto it = v.begin(); it != v.end(); ++it) {
                                if( it != v.begin() ) os << ", ";
                                        os << *it;
                                            }
                    return os << "]";
}
#define ln length()
#define all(x) x.begin(),x.end()
#define endl "\n"
#define NL cout<<'\n';
#define F first
#define S second
template < typename T >
ostream &operator << ( ostream & os, const multiset< T > &v ) {
            os << "[";
                for(auto it = v.begin(); it != v.end(); ++it) {
                                if( it != v.begin() ) os << ", ";
                                        os << *it;
                                            }
                    return os << "]";
}
#define disp(x) for(auto t : x )cout<<t<<" ";
#define for0(n) for(int i=0;i<n;i++)
#define for0j(n) for(int j=0;j<n;j++)
#define SS <<" "<<
#define arrin(a,n) vi a(n);for0(n){cin>>a[i];}
#define pf(x) cout<<x<<endl;
#define Check pf("Check")
#define gridin(num,n,m) for0(n){for0j(m) cin>>num[i][j];}
#define dispgrid(num,n,m) for0(n){for0j(m) cout<<num[i][j]<<" "; cout<<endl;}
template < typename F, typename S >
ostream &operator << ( ostream & os, const map< F, S > &v ) {
            os << "[";
                for(auto it = v.begin(); it != v.end(); ++it) {
                                if( it != v.begin() ) os << ", ";
                                        os << it -> first << " = " << it -> second ;
                                            }
                    return os << "]";
}
#define tkst(x) string x;cin >> x;
#define tk(a) int a;cin>>a;
#define tk2(a,b)tk(a)tk(b)
#define tk3(a,b,c)tk2(a,b)tk(c)
#define tk4(a,b,c,d)tk2(a,b)tk2(c,d)
#define tk5(a,b,c,d,e)tk4(a,b,c,d)tk(e)
#define tk6(a,b,c,d,e,f)tk3(a,b,c)tk3(d,e,f)
#define tk7(a,b,c,d,e,f,g)tk6(a,b,c,d,e,f)tk(g)
#define tk8(a,b,c,d,e,f,g,h)tk7(a,b,c,d,e,f,g)tk(h)
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vpii vector<pii>
#define acum accumulate
#define fmap gp_hash_table
#define LONG LLONG
const int MOD=1000000007;
const int N=100000;

vector<string> vec_splitter(string s) {
	s += ',';
	vector<string> res;
	while(!s.empty()) {
		res.push_back(s.substr(0, s.find(',')));
		s = s.substr(s.find(',') + 1);
	}
	return res;
}

void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx,
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
	if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") =  ";
	stringstream ss; ss << H;
	cerr << args[idx] << " = " << ss.str();
	debug_out(args, idx + 1, LINE_NUM, T...);
}

#ifndef ONLINE_JUDGE
#define db(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#endif

// To find number of elements less than k in array a
// answer would be int res = upper_bound(all(a),k) - a.bg

// To find number of elements greater than k in array a
// answer would be int res = a.ed - upper_bound(all(a),k)

int bruteForce(int n,int w,vi &a){
	int pref[n];
	pref[0]=a[0];
	for(int i=1;i<n;i++){
		pref[i]=pref[i-1]+a[i];
	}
	int res=0;
	// 2 3 0
	for(int i=0;i<=w;i++){
		vi temp;
		for(int j=0;j<n;j++){
			temp.pb(i+pref[j]);
		}
		bool hoga=true;
		for(int j=0;j<n;j++){
			if(temp[j]<0 || temp[j]>w){
				hoga=false;
				break;
			}
		}
		if(hoga)res++;
	}
	return res;
}

int fast_solve(int n,int w,vi &a){
	int pref[n];
	pref[0]=a[0];
	for(int i=1;i<n;i++){
		pref[i]=pref[i-1]+a[i];
	}
	// 2 3 0
//	Check
	//disp(pref)NL
	int mini = *min_element(pref,pref+n);
	int maxi = *max_element(pref,pref+n);

	int pos1 =max(0LL,-mini);
	if(pos1>w)return 0;
	for0(n){
		pref[i]+=pos1;
	}
//	disp(pref)NL
	maxi = *max_element(pref,pref+n);
	if(maxi>w)return 0;

	return w-maxi+1;
}

int32_t main(){
	ios_base::sync_with_stdio(false);cin.tie(0);
	tk2(n,w)
	arrin(a,n)
	pf( fast_solve(n,w,a))
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;

//methods: find_by_order(k); & order_of_key(k);
//To make it an ordered_multiset, use pairs of (value, time_of_insertion)
//to distinguish values which are similar

#define int long long
#define pii pair<int,int>
#define pb push_back
template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
            os << "{";
                for(auto it = v.begin(); it != v.end(); ++it) {
                                if( it != v.begin() ) os << ", ";
                                        os << *it;
                                            }
                    return os << "}";

}
#define vi vector<int>
#define ed end()
#define bg begin()
template < typename F, typename S >
ostream& operator << ( ostream& os, const pair< F, S > & p ) {
            return os << "(" << p.first << ", " << p.second << ")";
}
#define sz size()

template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
            os << "[";
                for(auto it = v.begin(); it != v.end(); ++it) {
                                if( it != v.begin() ) os << ", ";
                                        os << *it;
                                            }
                    return os << "]";
}
#define ln length()
#define all(x) x.begin(),x.end()
#define endl "\n"
#define NL cout<<'\n';
#define F first
#define S second
template < typename T >
ostream &operator << ( ostream & os, const multiset< T > &v ) {
            os << "[";
                for(auto it = v.begin(); it != v.end(); ++it) {
                                if( it != v.begin() ) os << ", ";
                                        os << *it;
                                            }
                    return os << "]";
}
#define disp(x) for(auto t : x )cout<<t<<" ";
#define for0(n) for(int i=0;i<n;i++)
#define for0j(n) for(int j=0;j<n;j++)
#define SS <<" "<<
#define arrin(a,n) vi a(n);for0(n){cin>>a[i];}
#define pf(x) cout<<x<<endl;
#define Check pf("Check")
#define gridin(num,n,m) for0(n){for0j(m) cin>>num[i][j];}
#define dispgrid(num,n,m) for0(n){for0j(m) cout<<num[i][j]<<" "; cout<<endl;}
template < typename F, typename S >
ostream &operator << ( ostream & os, const map< F, S > &v ) {
            os << "[";
                for(auto it = v.begin(); it != v.end(); ++it) {
                                if( it != v.begin() ) os << ", ";
                                        os << it -> first << " = " << it -> second ;
                                            }
                    return os << "]";
}
#define tkst(x) string x;cin >> x;
#define tk(a) int a;cin>>a;
#define tk2(a,b)tk(a)tk(b)
#define tk3(a,b,c)tk2(a,b)tk(c)
#define tk4(a,b,c,d)tk2(a,b)tk2(c,d)
#define tk5(a,b,c,d,e)tk4(a,b,c,d)tk(e)
#define tk6(a,b,c,d,e,f)tk3(a,b,c)tk3(d,e,f)
#define tk7(a,b,c,d,e,f,g)tk6(a,b,c,d,e,f)tk(g)
#define tk8(a,b,c,d,e,f,g,h)tk7(a,b,c,d,e,f,g)tk(h)
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vpii vector<pii>
#define acum accumulate
#define fmap gp_hash_table
#define LONG LLONG
const int MOD=1000000007;
const int N=100000;

vector<string> vec_splitter(string s) {
	s += ',';
	vector<string> res;
	while(!s.empty()) {
		res.push_back(s.substr(0, s.find(',')));
		s = s.substr(s.find(',') + 1);
	}
	return res;
}

void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx,
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
	if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") =  ";
	stringstream ss; ss << H;
	cerr << args[idx] << " = " << ss.str();
	debug_out(args, idx + 1, LINE_NUM, T...);
}

#ifndef ONLINE_JUDGE
#define db(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#endif

// To find number of elements less than k in array a
// answer would be int res = upper_bound(all(a),k) - a.bg

// To find number of elements greater than k in array a
// answer would be int res = a.ed - upper_bound(all(a),k)

int32_t main(){
	ios_base::sync_with_stdio(false);cin.tie(0);
	tk2(n,w)
	arrin(a,n)
	int pref[n];
	pref[0]=a[0];
	for(int i=1;i<n;i++){
		pref[i]=pref[i-1]+a[i];
	}
	int res=0;
	// 2 3 0
	for(int i=0;i<=w;i++){
		vi temp;
		for(int j=0;j<n;j++){
			temp.pb(i+pref[j]);
		}
		bool hoga=true;
		for(int j=0;j<n;j++){
			if(temp[j]<0 || temp[j]>w){
				hoga=false;
				break;
			}
		}
		if(hoga)res++;
	}
	pf(res)
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;

//methods: find_by_order(k); & order_of_key(k);
//To make it an ordered_multiset, use pairs of (value, time_of_insertion)
//to distinguish values which are similar

#define int long long
#define pii pair<int,int>
#define pb push_back
template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
            os << "{";
                for(auto it = v.begin(); it != v.end(); ++it) {
                                if( it != v.begin() ) os << ", ";
                                        os << *it;
                                            }
                    return os << "}";

}
#define vi vector<int>
#define ed end()
#define bg begin()
template < typename F, typename S >
ostream& operator << ( ostream& os, const pair< F, S > & p ) {
            return os << "(" << p.first << ", " << p.second << ")";
}
#define sz size()

template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
            os << "[";
                for(auto it = v.begin(); it != v.end(); ++it) {
                                if( it != v.begin() ) os << ", ";
                                        os << *it;
                                            }
                    return os << "]";
}
#define ln length()
#define all(x) x.begin(),x.end()
#define endl "\n"
#define NL cout<<'\n';
#define F first
#define S second
template < typename T >
ostream &operator << ( ostream & os, const multiset< T > &v ) {
            os << "[";
                for(auto it = v.begin(); it != v.end(); ++it) {
                                if( it != v.begin() ) os << ", ";
                                        os << *it;
                                            }
                    return os << "]";
}
#define disp(x) for(auto t : x )cout<<t<<" ";
#define for0(n) for(int i=0;i<n;i++)
#define for0j(n) for(int j=0;j<n;j++)
#define SS <<" "<<
#define arrin(a,n) vi a(n);for0(n){cin>>a[i];}
#define pf(x) cout<<x<<endl;
#define Check pf("Check")
#define gridin(num,n,m) for0(n){for0j(m) cin>>num[i][j];}
#define dispgrid(num,n,m) for0(n){for0j(m) cout<<num[i][j]<<" "; cout<<endl;}
template < typename F, typename S >
ostream &operator << ( ostream & os, const map< F, S > &v ) {
            os << "[";
                for(auto it = v.begin(); it != v.end(); ++it) {
                                if( it != v.begin() ) os << ", ";
                                        os << it -> first << " = " << it -> second ;
                                            }
                    return os << "]";
}
#define tkst(x) string x;cin >> x;
#define tk(a) int a;cin>>a;
#define tk2(a,b)tk(a)tk(b)
#define tk3(a,b,c)tk2(a,b)tk(c)
#define tk4(a,b,c,d)tk2(a,b)tk2(c,d)
#define tk5(a,b,c,d,e)tk4(a,b,c,d)tk(e)
#define tk6(a,b,c,d,e,f)tk3(a,b,c)tk3(d,e,f)
#define tk7(a,b,c,d,e,f,g)tk6(a,b,c,d,e,f)tk(g)
#define tk8(a,b,c,d,e,f,g,h)tk7(a,b,c,d,e,f,g)tk(h)
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vpii vector<pii>
#define acum accumulate
#define fmap gp_hash_table
#define LONG LLONG
const int MOD=1000000007;
const int N=100000;

vector<string> vec_splitter(string s) {
	s += ',';
	vector<string> res;
	while(!s.empty()) {
		res.push_back(s.substr(0, s.find(',')));
		s = s.substr(s.find(',') + 1);
	}
	return res;
}

void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx,
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
	if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") =  ";
	stringstream ss; ss << H;
	cerr << args[idx] << " = " << ss.str();
	debug_out(args, idx + 1, LINE_NUM, T...);
}

#ifndef ONLINE_JUDGE
#define db(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#endif

// To find number of elements less than k in array a
// answer would be int res = upper_bound(all(a),k) - a.bg

// To find number of elements greater than k in array a
// answer would be int res = a.ed - upper_bound(all(a),k)

int bruteForce(int n,int w,vi &a){
	int pref[n];
	pref[0]=a[0];
	for(int i=1;i<n;i++){
		pref[i]=pref[i-1]+a[i];
	}
	int res=0;
	// 2 3 0
	for(int i=0;i<=w;i++){
		vi temp;
		for(int j=0;j<n;j++){
			temp.pb(i+pref[j]);
		}
		bool hoga=true;
		for(int j=0;j<n;j++){
			if(temp[j]<0 || temp[j]>w){
				hoga=false;
				break;
			}
		}
		if(hoga)res++;
	}
	return res;
}

int fast_solve(int n,int w,vi &a){
	int pref[n];
	pref[0]=a[0];
	for(int i=1;i<n;i++){
		pref[i]=pref[i-1]+a[i];
	}
	int res=0;
	// 2 3 0
//	Check
	//disp(pref)NL
	int mini = *min_element(pref,pref+n);
	int maxi = *max_element(pref,pref+n);
	if(maxi>w)return 0;
	int pos1 =max(0LL,-mini);
	int pos2 = w-maxi;
//	pf("CD " SS pos1 SS pos2)
	return pos2-pos1+1;
}
vector<int> generateArray(int n){
	srand(time(NULL));
	vector<int> res;
	int elem_size=100;
	for(int i=0;i<n;i++){
		res.push_back(rand()%elem_size+1*(rand()%2==0?-1:1));
	}
	return res;
}

int32_t main(){
	ios_base::sync_with_stdio(false);cin.tie(0);
	tk2(n,w)
	arrin(a,n)
	if(w<=10000){
		pf(bruteForce(n,w,a))
	}else{
		pf(fast_solve(n,w,a))
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;

//methods: find_by_order(k); & order_of_key(k);
//To make it an ordered_multiset, use pairs of (value, time_of_insertion)
//to distinguish values which are similar

#define int long long
#define pii pair<int,int>
#define pb push_back
template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
            os << "{";
                for(auto it = v.begin(); it != v.end(); ++it) {
                                if( it != v.begin() ) os << ", ";
                                        os << *it;
                                            }
                    return os << "}";

}
#define vi vector<int>
#define ed end()
#define bg begin()
template < typename F, typename S >
ostream& operator << ( ostream& os, const pair< F, S > & p ) {
            return os << "(" << p.first << ", " << p.second << ")";
}
#define sz size()

template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
            os << "[";
                for(auto it = v.begin(); it != v.end(); ++it) {
                                if( it != v.begin() ) os << ", ";
                                        os << *it;
                                            }
                    return os << "]";
}
#define ln length()
#define all(x) x.begin(),x.end()
#define endl "\n"
#define NL cout<<'\n';
#define F first
#define S second
template < typename T >
ostream &operator << ( ostream & os, const multiset< T > &v ) {
            os << "[";
                for(auto it = v.begin(); it != v.end(); ++it) {
                                if( it != v.begin() ) os << ", ";
                                        os << *it;
                                            }
                    return os << "]";
}
#define disp(x) for(auto t : x )cout<<t<<" ";
#define for0(n) for(int i=0;i<n;i++)
#define for0j(n) for(int j=0;j<n;j++)
#define SS <<" "<<
#define arrin(a,n) vi a(n);for0(n){cin>>a[i];}
#define pf(x) cout<<x<<endl;
#define Check pf("Check")
#define gridin(num,n,m) for0(n){for0j(m) cin>>num[i][j];}
#define dispgrid(num,n,m) for0(n){for0j(m) cout<<num[i][j]<<" "; cout<<endl;}
template < typename F, typename S >
ostream &operator << ( ostream & os, const map< F, S > &v ) {
            os << "[";
                for(auto it = v.begin(); it != v.end(); ++it) {
                                if( it != v.begin() ) os << ", ";
                                        os << it -> first << " = " << it -> second ;
                                            }
                    return os << "]";
}
#define tkst(x) string x;cin >> x;
#define tk(a) int a;cin>>a;
#define tk2(a,b)tk(a)tk(b)
#define tk3(a,b,c)tk2(a,b)tk(c)
#define tk4(a,b,c,d)tk2(a,b)tk2(c,d)
#define tk5(a,b,c,d,e)tk4(a,b,c,d)tk(e)
#define tk6(a,b,c,d,e,f)tk3(a,b,c)tk3(d,e,f)
#define tk7(a,b,c,d,e,f,g)tk6(a,b,c,d,e,f)tk(g)
#define tk8(a,b,c,d,e,f,g,h)tk7(a,b,c,d,e,f,g)tk(h)
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vpii vector<pii>
#define acum accumulate
#define fmap gp_hash_table
#define LONG LLONG
const int MOD=1000000007;
const int N=100000;

vector<string> vec_splitter(string s) {
	s += ',';
	vector<string> res;
	while(!s.empty()) {
		res.push_back(s.substr(0, s.find(',')));
		s = s.substr(s.find(',') + 1);
	}
	return res;
}

void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx,
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
	if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") =  ";
	stringstream ss; ss << H;
	cerr << args[idx] << " = " << ss.str();
	debug_out(args, idx + 1, LINE_NUM, T...);
}

#ifndef ONLINE_JUDGE
#define db(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#endif

// To find number of elements less than k in array a
// answer would be int res = upper_bound(all(a),k) - a.bg

// To find number of elements greater than k in array a
// answer would be int res = a.ed - upper_bound(all(a),k)

int bruteForce(int n,int w,vi &a){
	int pref[n];
	pref[0]=a[0];
	for(int i=1;i<n;i++){
		pref[i]=pref[i-1]+a[i];
	}
	int res=0;
	// 2 3 0
	for(int i=0;i<=w;i++){
		vi temp;
		for(int j=0;j<n;j++){
			temp.pb(i+pref[j]);
		}
		bool hoga=true;
		for(int j=0;j<n;j++){
			if(temp[j]<0 || temp[j]>w){
				hoga=false;
				break;
			}
		}
		if(hoga)res++;
	}
	return res;
}

int fast_solve(int n,int w,vi &a){
	int pref[n];
	pref[0]=a[0];
	for(int i=1;i<n;i++){
		pref[i]=pref[i-1]+a[i];
	}
	// 2 3 0
//	Check
	//disp(pref)NL
	int mini = *min_element(pref,pref+n);
	int maxi = *max_element(pref,pref+n);

	int pos1 =max(0LL,-mini);
	if(pos1>w)return 0;
	for0(n){
		pref[i]+=pos1;
	}
	//disp(pref)NL
	maxi = *max_element(pref,pref+n);
	maxi = max(maxi,pos1);
	if(maxi>w)return 0;

	return w-maxi+1;
}

int32_t main(){
	ios_base::sync_with_stdio(false);cin.tie(0);
	tk2(n,w)
	arrin(a,n)
	pf( fast_solve(n,w,a))
	return 0;
}


//#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <vector>
#include <string>
#include <climits>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
using namespace std;
#define loop(n) for(int i=0;i<n;i++)
#define endl '\n'
#define OnlineJudgec
#define F first
#define S second
#define  precision(n)  cout << fixed << setprecision(n)
#define clr(v,d ) memset(v, d, sizeof(v))
typedef long long ll;
typedef vector<int> vi;
void init()
{
    cin.tie(0);
    cin.sync_with_stdio(0);
    cout.tie(0);
#ifdef OnlineJudge
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
#endif
}
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};
/// <<------------------------------------------------------------------------------>>
int arr[1010];
int n,w,lower,upper;
bool valid(int x,int y)
{
    return (x >= 0 && x <= w && y >= 0 && y <= w);
}
bool check(int value)// checking on some value of x
{
    int x = value,y;
    y = value + arr[0];
    if(!valid(x,y))return 0;
    for(int i = 1 ;i < n;i++)
    {
        x = y;
        y = x + arr[i];
        if(!valid(x,y))return 0;
    }
    return 1;
}
int BS(int w)
{
    int l = lower , r = w , mid,rst = 0;
    bool ok = 0;
    while(l <= r)
    {
        mid = (l+r)/ 2;
        if(check(mid))
        {
            l = mid + 1;
           rst= mid;
        }
        else r = mid - 1;
    }
    return rst;
}
int BS2(int w)
{
    int l = 0, r = w , mid,rst = 0;
    while(l <= r)
    {
        mid = (l+r)/ 2;
        if(check(mid))
        {
            r = mid - 1;
           rst= mid;
        }
        else l = mid + 1;
    }
    return rst;
}
/// <<------------------------------------------------------------------------------>>
int main()
{
    init();
    cin >> n >> w;
    loop(n)cin >> arr[i];
    lower = BS2(w);
    upper = BS(w);
    /// 0 0 0 [1 1 1 1] 0 0 0
    if(!upper && ! lower)lower = 1;
    cout<<upper - lower + 1<<endl;
}


//#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <vector>
#include <string>
#include <climits>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
using namespace std;
#define loop(n) for(int i=0;i<n;i++)
#define endl '\n'
#define OnlineJudgec
#define F first
#define S second
#define  precision(n)  cout << fixed << setprecision(n)
#define clr(v,d ) memset(v, d, sizeof(v))
typedef long long ll;
typedef vector<int> vi;
void init()
{
    cin.tie(0);
    cin.sync_with_stdio(0);
    cout.tie(0);
#ifdef OnlineJudge
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
#endif
}
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};
/// <<------------------------------------------------------------------------------>>

/// <<------------------------------------------------------------------------------>>
int main()
{
    init();
    int n,w;
    cin >> n >>w;
    int arr[n];loop(n)cin >> arr[i];
    int mn = 0 , mx = w,delta = 0;
    loop(n)
    {
        delta += arr[i];
        mx = min(mx,min(w,w-delta));
        mn = max(mn,-delta);
    }
    if(mn > w)return cout<< 0 , 0;
    cout<<mx - mn + 1<<endl;
}


//#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <vector>
#include <string>
#include <climits>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
using namespace std;
#define loop(n) for(int i=0;i<n;i++)
#define endl '\n'
#define OnlineJudgec
#define F first
#define S second
#define  precision(n)  cout << fixed << setprecision(n)
#define clr(v,d ) memset(v, d, sizeof(v))
typedef long long ll;
typedef vector<int> vi;
void init()
{
    cin.tie(0);
    cin.sync_with_stdio(0);
    cout.tie(0);
#ifdef OnlineJudge
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
#endif
}
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};
/// <<------------------------------------------------------------------------------>>
int arr[1010];
int n,w,lower,upper;
bool check(int value)// checking on some value of x
{
    loop(n)value+= arr[i];
    if(value>w)return 0;
    return 1;
}
bool check2(int value)
{
    loop(n)value += arr[i];
    if(value<0)return 0;
    return 1;
}
int BS(int w)//upper
{
    int l = lower , r = w , mid,rst = -1;
    bool ok = 0;
    while(l <= r)
    {
        mid = (l+r)/ 2;
        if(check(mid))
        {
            l = mid + 1;
           rst= mid;
        }
        else r = mid - 1;
    }
    return rst;
}
int BS2(int w)
{
    int l = 0, r = w , mid,rst = -1;
    while(l <= r)
    {
        mid = (l+r)/ 2;
        if(check2(mid))
        {
            r = mid - 1;
           rst= mid;
        }
        else l = mid + 1;
    }
    return rst;
}
/// <<------------------------------------------------------------------------------>>
int main()
{
    init();
    cin >> n >> w;
    loop(n)cin >> arr[i];
    lower = BS2(w);/// 0 0 0 0 0 1 1 1 1 1
    upper = BS(w) ;
    if(upper == -1 || lower == -1)return cout<<0, 0;
    cout<<upper - lower + 1<<endl;
}


//#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <vector>
#include <string>
#include <climits>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
using namespace std;
#define loop(n) for(int i=0;i<n;i++)
#define endl '\n'
#define OnlineJudgec
#define F first
#define S second
#define  precision(n)  cout << fixed << setprecision(n)
#define clr(v,d ) memset(v, d, sizeof(v))
typedef long long ll;
typedef vector<int> vi;
void init()
{
    cin.tie(0);
    cin.sync_with_stdio(0);
    cout.tie(0);
#ifdef OnlineJudge
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
#endif
}
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};
/// <<------------------------------------------------------------------------------>>
int arr[1010];
int n,w,lower,upper;
bool check(int value)// checking on some value of x
{
    loop(n)
    {
        value += arr[i];
        if(value>w)return 0;
    }
    return 1;
}
bool check2(int value)
{
    loop(n)
    {
        value += arr[i];
        if(value<0)return 0;
    }
    return 1;
}
int BS(int w)//upper
{
    int l = lower , r = w , mid,rst = -1;
    bool ok = 0;
    while(l <= r)
    {
        mid = (l+r)/ 2;
        if(check(mid))
        {
            l = mid + 1;
           rst= mid;
        }
        else r = mid - 1;
    }
    return rst;
}
int BS2(int w)
{
    int l = 0, r = w , mid,rst = -1;
    while(l <= r)
    {
        mid = (l+r)/ 2;
        if(check2(mid))
        {
            r = mid - 1;
           rst= mid;
        }
        else l = mid + 1;
    }
    return rst;
}
/// <<------------------------------------------------------------------------------>>
int main()
{
    init();
    cin >> n >> w;
    loop(n)cin >> arr[i];
    lower = BS2(w);/// 0 0 0 0 0 1 1 1 1 1
    upper = BS(w);
    if(upper == -1 || lower == -1)return cout<<0, 0;
    cout<<upper - lower + 1<<endl;
}


//#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <vector>
#include <string>
#include <climits>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
using namespace std;
#define loop(n) for(int i=0;i<n;i++)
#define endl '\n'
#define OnlineJudgec
#define F first
#define S second
#define  precision(n)  cout << fixed << setprecision(n)
#define clr(v,d ) memset(v, d, sizeof(v))
typedef long long ll;
typedef vector<int> vi;
void init()
{
    cin.tie(0);
    cin.sync_with_stdio(0);
    cout.tie(0);
#ifdef OnlineJudge
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
#endif
}
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};
/// <<------------------------------------------------------------------------------>>

/// <<------------------------------------------------------------------------------>>
int main()
{
    init();
    int n,w;
    cin >> n >>w;
    int arr[n];loop(n)cin >> arr[i];
    int mn = 0 , mx = w,delta = 0;
    loop(n)
    {
        delta += arr[i];
        mx = min(mx,min(w,w-delta));
        mn = max(mn,-delta);
    }
    if(mn > mx)return cout<< 0 , 0;
    cout<<mx - mn + 1<<endl;
}


//#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <vector>
#include <string>
#include <climits>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
using namespace std;
#define loop(n) for(int i=0;i<n;i++)
#define endl '\n'
#define OnlineJudgec
#define F first
#define S second
#define  precision(n)  cout << fixed << setprecision(n)
#define clr(v,d ) memset(v, d, sizeof(v))
typedef long long ll;
typedef vector<int> vi;
void init()
{
    cin.tie(0);
    cin.sync_with_stdio(0);
    cout.tie(0);
#ifdef OnlineJudge
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
#endif
}
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};
/// <<------------------------------------------------------------------------------>>
int arr[1010];
int n,w;
bool valid(int x,int y)
{
    return (x >= 0 && x <= w && y >= 0 && y <= w);
}
bool check(int value)// checking on some value of x
{
    int x = value,y;
    y = value + arr[0];
    if(!valid(x,y))return 0;
    for(int i = 1 ;i < n;i++)
    {
        x = y;
        y = x + arr[i];
        if(!valid(x,y))return 0;
    }
    return 1;
}
int BS(int w)
{
    int l = 0 , r = w , mid,rst = 0;
    while(l <= r)
    {
        mid = (l+r)/ 2;
        if(check(mid))
        {
            l = mid + 1;
           rst= mid;
        }
        else r = mid - 1;
    }
    return rst;
}
int BS2(int w)
{
    int l = 0 , r = w , mid,rst = 0;
    while(l <= r)
    {
        mid = (l+r)/ 2;
        if(check(mid))
        {
            r = mid - 1;
           rst= mid;
        }
        else l = mid + 1;
    }
    return rst;
}
/// <<------------------------------------------------------------------------------>>
int main()
{
    init();
    cin >> n >> w;
    loop(n)cin >> arr[i];
    int upper = BS(w);
    int lower = BS2(w);
    /// 0 0 0 [1 1 1 1] 0 0 0
    cout<<upper - lower + 1<<endl;
}


//#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <vector>
#include <string>
#include <climits>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
using namespace std;
#define loop(n) for(int i=0;i<n;i++)
#define endl '\n'
#define OnlineJudgec
#define F first
#define S second
#define  precision(n)  cout << fixed << setprecision(n)
#define clr(v,d ) memset(v, d, sizeof(v))
typedef long long ll;
typedef vector<int> vi;
void init()
{
    cin.tie(0);
    cin.sync_with_stdio(0);
    cout.tie(0);
#ifdef OnlineJudge
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
#endif
}
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};
/// <<------------------------------------------------------------------------------>>
int arr[1010];
int n,w;
bool valid(int x,int y)
{
    return (x >= 0 && x <= w && y >= 0 && y <= w);
}
bool check(int value)// checking on some value of x
{
    int x = value,y;
    y = value + arr[0];
    if(!valid(x,y))return 0;
    for(int i = 1 ;i < n;i++)
    {
        x = y;
        y = x + arr[i];
        if(!valid(x,y))return 0;
    }
    return 1;
}
int BS(int w)
{
    int l = 0 , r = w , mid,rst = 0;
    while(l <= r)
    {
        mid = (l+r)/ 2;
        if(check(mid))
        {
            l = mid + 1;
           rst= mid;
        }
        else r = mid - 1;
    }
    return rst;
}
int BS2(int w)
{
    int l = 0 , r = w , mid,rst = 0;
    while(l <= r)
    {
        mid = (l+r)/ 2;
        if(check(mid))
        {
            r = mid - 1;
           rst= mid;
        }
        else l = mid + 1;
    }
    return rst;
}
/// <<------------------------------------------------------------------------------>>
int main()
{
    init();
    cin >> n >> w;
    loop(n)cin >> arr[i];
    int upper = BS(w);
    int lower = BS2(w);
    /// 0 0 0 [1 1 1 1] 0 0 0
    if(!upper && ! lower)lower = 1;
    cout<<upper - lower + 1<<endl;
}


#include <bits/stdc++.h>

#define ll long long
#define ld long double
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define for0(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define forr(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define forab(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define foriter(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define endl '\n'
#define INF (ll)(1e9)
#define EPS 1e-9
#define MOD (ll)(1e9+7)
#define PI 3.1415926535897932384626433832795
#define set set
#define mset multiset
#define uset unordered_set
#define umset unordered_multiset
#define map map
#define mmap multimap
#define umap unordered_map
#define ummap unordered_multimap

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vll;
typedef vector<vll> vvll;
typedef pair<i64, i64> pll;

template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

//=============================================================================//

void solve() {
    int n, w; cin>>n>>w;
    vi a(n); for0(i, n) cin>>a[i];
    ll mx = -INF, mn = INF;
    ll sum = 0;
    for0(i, n) {
        sum+=a[i];
        mn = min(mn, sum);
        mx = max(mx, sum);
    }
    ll ans = w-mx - mn + 1;
    if(mx>w || -mn>w || ans > w+1 || ans<0) cout<<0;
    else cout<<ans;

int main() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);

    int T=1;
    //cin >> T;
    while (T--) {
        solve();
        cout<<endl;
    }

    return 0;
}


#include <bits/stdc++.h>

#define ll long long
#define ld long double
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define for0(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define forr(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define forab(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define foriter(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define endl '\n'
#define INF (ll)(1e9)
#define EPS 1e-9
#define MOD (ll)(1e9+7)
#define PI 3.1415926535897932384626433832795
#define set set
#define mset multiset
#define uset unordered_set
#define umset unordered_multiset
#define map map
#define mmap multimap
#define umap unordered_map
#define ummap unordered_multimap

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vll;
typedef vector<vll> vvll;
typedef pair<i64, i64> pll;

template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

//=============================================================================//

void solve() {

}

int main() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);

    int T=1;
    cin >> T;
    while (T--) {
        solve();
        cout<<endl;
    }

    return 0;
}


#include <bits/stdc++.h>

#define ll long long
#define ld long double
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define for0(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define forr(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define forab(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define foriter(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define endl '\n'
#define INF (ll)(1e9)
#define EPS 1e-9
#define MOD (ll)(1e9+7)
#define PI 3.1415926535897932384626433832795
#define set set
#define mset multiset
#define uset unordered_set
#define umset unordered_multiset
#define map map
#define mmap multimap
#define umap unordered_map
#define ummap unordered_multimap

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vll;
typedef vector<vll> vvll;
typedef pair<i64, i64> pll;

template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

//=============================================================================//

void solve() {
    int n, w; cin>>n>>w;
    vi a(n); for0(i, n) cin>>a[i];
    ll mx = -INF, mn = INF;
    ll sum = 0;
    for0(i, n) {
        sum+=a[i];
        mx = max(mx, sum);
        mn = min(mn, sum);
    }
    ll lb = max(0LL, -mn);
    ll ub = max(0LL, w-mx);
    if(ub<lb) cout<<0;
    else cout<<ub-lb+1;
}

int main() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);

    int T=1;
    //cin >> T;
    while (T--) {
        solve();
        cout<<endl;
    }

    return 0;
}


#include <bits/stdc++.h>

#define ll long long
#define ld long double
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define for0(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define forr(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define forab(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define foriter(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define endl '\n'
#define INF (ll)(1e9)
#define EPS 1e-9
#define MOD (ll)(1e9+7)
#define PI 3.1415926535897932384626433832795
#define set set
#define mset multiset
#define uset unordered_set
#define umset unordered_multiset
#define map map
#define mmap multimap
#define umap unordered_map
#define ummap unordered_multimap

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vll;
typedef vector<vll> vvll;
typedef pair<i64, i64> pll;

template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

//=============================================================================//

void solve() {
    int n, w; cin>>n>>w;
    vi a(n); for0(i, n) cin>>a[i];
    ll mx = -INF, mn = INF;
    ll sum = 0;
    for0(i, n) {
        sum+=a[i];
        mx = max(mx, sum);
        mn = min(mn, sum);
    }
    ll lb = max(0LL, -mn);
    ll ub = w-mx;
    if(ub<lb) cout<<0;
    else cout<<ub-lb+1;
}

int main() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);

    int T=1;
    //cin >> T;
    while (T--) {
        solve();
        cout<<endl;
    }

    return 0;
}


#include <bits/stdc++.h>

#define ll long long
#define ld long double
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define for0(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define forr(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define forab(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define foriter(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define endl '\n'
#define INF (ll)(1e9)
#define EPS 1e-9
#define MOD (ll)(1e9+7)
#define PI 3.1415926535897932384626433832795
#define set set
#define mset multiset
#define uset unordered_set
#define umset unordered_multiset
#define map map
#define mmap multimap
#define umap unordered_map
#define ummap unordered_multimap

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vll;
typedef vector<vll> vvll;
typedef pair<i64, i64> pll;

template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

//=============================================================================//

void solve() {
    int n, w; cin>>n>>w;
    vi a(n); for0(i, n) cin>>a[i];
    ll mx = -INF, mn = INF;
    ll sum = 0;
    for0(i, n) {
        sum+=a[i];
        mn = min(mn, sum);
        mx = max(mx, sum);
    }
    ll ans = w-mx - mn + 1;
    if(mx>w || -mn>w || ans > w+1 || ans<0) cout<<0;
    else cout<<ans;
}

int main() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);

    int T=1;
    //cin >> T;
    while (T--) {
        solve();
        cout<<endl;
    }

    return 0;
}


#include <bits/stdc++.h>

#define ll long long
#define ld long double
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define for0(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define forr(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define forab(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define foriter(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define endl '\n'
#define INF (ll)(1e9)
#define EPS 1e-9
#define MOD (ll)(1e9+7)
#define PI 3.1415926535897932384626433832795
#define set set
#define mset multiset
#define uset unordered_set
#define umset unordered_multiset
#define map map
#define mmap multimap
#define umap unordered_map
#define ummap unordered_multimap

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vll;
typedef vector<vll> vvll;
typedef pair<i64, i64> pll;

template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

//=============================================================================//

void solve() {
    int n, w; cin>>n>>w;
    vi a(n); for0(i, n) cin>>a[i];
    ll mx = -INF, mn = 0;
    ll sum = 0;
    for0(i, n) {
        sum+=a[i];
        if(sum<0) mn = -sum;
        mx = max(mx, sum);
    }
    if(w-mx<mn || mx>w || mn>w) cout<<0;
    else cout<<w-mx-mn+1;
}

int main() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);

    int T=1;
    //cin >> T;
    while (T--) {
        solve();
        cout<<endl;
    }

    return 0;
}


#include <bits/stdc++.h>

#define ll long long
#define ld long double
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define for0(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define forr(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define forab(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define foriter(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define endl '\n'
#define INF (ll)(1e9)
#define EPS 1e-9
#define MOD (ll)(1e9+7)
#define PI 3.1415926535897932384626433832795
#define set set
#define mset multiset
#define uset unordered_set
#define umset unordered_multiset
#define map map
#define mmap multimap
#define umap unordered_map
#define ummap unordered_multimap

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vll;
typedef vector<vll> vvll;
typedef pair<i64, i64> pll;

template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

//=============================================================================//

void solve() {
    int n, w; cin>>n>>w;
    vi a(n); for0(i, n) cin>>a[i];
    ll mx = -INF, mn = 0;
    ll sum = 0;
    for0(i, n) {
        sum+=a[i];
        if(sum<0) mn = -sum;
        if(sum>w) {cout<<0; return;}
        mx = max(mx, sum);
    }
    if(w-mx<mn || mx>w) cout<<0;
    else cout<<w-mx-mn+1;
}

int main() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);

    int T=1;
    //cin >> T;
    while (T--) {
        solve();
        cout<<endl;
    }

    return 0;
}


#include <bits/stdc++.h>

#define ll long long
#define ld long double
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define for0(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define forr(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define forab(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define foriter(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define endl '\n'
#define INF (ll)(1e9)
#define EPS 1e-9
#define MOD (ll)(1e9+7)
#define PI 3.1415926535897932384626433832795
#define set set
#define mset multiset
#define uset unordered_set
#define umset unordered_multiset
#define map map
#define mmap multimap
#define umap unordered_map
#define ummap unordered_multimap

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vll;
typedef vector<vll> vvll;
typedef pair<i64, i64> pll;

template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

//=============================================================================//

void solve() {
    int n, w; cin>>n>>w;
    vi a(n); for0(i, n) cin>>a[i];
    ll mx = 0, mn = 0;
    ll sum = 0;
    for0(i, n) {
        sum+=a[i];
        mn = min(mn, sum);
        mx = max(mx, sum);
    }
    ll ans = w-mx + mn + 1;
    if(mx>w || (-1*mn)>w || ans > w+1 || ans<0) cout<<0;
    else cout<<ans;
}

int main() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);

    int T=1;
    //cin >> T;
    while (T--) {
        solve();
        cout<<endl;
    }

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1010;
const ll INF = (1<<31)-1;
ll sum[maxn];
ll n,w;
int main()
{
	while(scanf("%lld%lld",&n,&w)!=EOF)
	{
		memset(sum,0,sizeof(sum));
		ll MAX = -INF;
		ll MIN = INF;
		for(int i=1;i<=n;i++)
		{
			ll tmp;
			scanf("%lld",&tmp);
			sum[i]=tmp+sum[i-1];
			//cout<<sum[i]<<" ";
		}
		cout<<endl;
		for(int i=1;i<=n;i++)
		{
			MAX = max(sum[i],MAX);
			MIN = min(sum[i],MIN);
		}
		if(MIN>=0 && MAX>=0)
		{
			if(w-MAX+1>0)
			{
				cout<<w-MAX+1<<endl;
			}
			else
			{
				cout<<0<<endl;
			}
		}
		else if(MIN<0 && MAX>=0)
		{
			if(w-MAX+1+MIN>0)
			{
				cout<<w-MAX+1+MIN<<endl;
			}
			else
			{
				cout<<0<<endl;
			}
		}
		else if(MIN<0 && MAX<0)
		{
			if(w+MIN>0)
			{
				cout<<w+MIN+1<<endl;
				break;
			}
			else if(MIN == MAX && -MIN*n<=w)
			{
				cout<<w-MIN*n+1<<endl;
				break;
			}
			else if(MIN == MAX && -MIN*n>w)
			{
				cout<<0<<endl;
				break;
			}
			else
			{
				cout<<0<<endl;
			}
		}
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1010;
const ll INF = (1<<31)-1;
ll sum[maxn];
ll n,w;
int main()
{
	while(scanf("%lld%lld",&n,&w)!=EOF)
	{
		memset(sum,0,sizeof(sum));
		ll MAX = -INF;
		ll MIN = INF;
		for(int i=1;i<=n;i++)
		{
			ll tmp;
			scanf("%lld",&tmp);
			sum[i]=tmp+sum[i-1];
			cout<<sum[i]<<" ";
		}
		cout<<endl;
		for(int i=1;i<=n;i++)
		{
			MAX = max(sum[i],MAX);
			MIN = min(sum[i],MIN);
		}
		if(MIN>=0 && MAX>=0)
		{
			if(w-MAX+1>0)
			{
				cout<<w-MAX+1<<endl;
			}
			else
			{
				cout<<0<<endl;
			}
		}
		else if(MIN<0 && MAX>=0)
		{
			if(w-MAX+1+MIN>0)
			{
				cout<<w-MAX+1+MIN<<endl;
			}
			else
			{
				cout<<0<<endl;
			}
		}
		else if(MIN<0 && MAX<0)
		{
			if(w+MAX+MIN>0)
			{
				cout<<w+MAX+MIN<<endl;
			}
			else
			{
				cout<<0<<endl;
			}
		}
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1010;
const ll INF = (1<<31)-1;
ll sum[maxn];
ll n,w;
int main()
{
	while(scanf("%lld%lld",&n,&w)!=EOF)
	{
		memset(sum,0,sizeof(sum));
		ll MAX = 0;
		ll MIN = 0;
		for(int i=1;i<=n;i++)
		{
			ll tmp;
			scanf("%lld",&tmp);
			sum[i]=tmp+sum[i-1];
			//cout<<sum[i]<<" ";
		}
		for(int i=1;i<=n;i++)
		{
			MAX = max(sum[i],MAX);
			MIN = min(sum[i],MIN);
		}
		cout<<max(0ll,w-MAX+MIN+1)<<endl;
	}
	return 0;
}