#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000001;
const float PI = 3.14;
typedef map<string, int> msi;
typedef vector<pair<int, int> > vii;
typedef priority_queue<pair<int, int>, vector<pair<int, int> >,
                       greater<pair<int, int> > >
    pq;
vector<pair<int, int> >::iterator iter;
int n, w;
int a[100005];
int main(int argc, char* argv[]) {
  cin >> n >> w;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int maxB = 0;
  int minB = INF;
  int b = 0;
  for (int i = 0; i < n; i++) {
    b += a[i];
    maxB = max(maxB, b);
    minB = min(minB, b);
  }
  if (maxB > w) {
    cout << '0' << '\n';
  } else {
    int one;
    int two;
    if (minB < 0) {
      one = -minB;
    } else
      one = 0;
    if (maxB <= 0) {
      two = w;
    } else
      two = w - maxB;
    if (one > two)
      cout << '0' << '\n';
    else
      cout << two - one + 1 << '\n';
  }
  return 0;
}
