#include <bits/stdc++.h>
using namespace std;
long long int toint(const string &s) {
  stringstream ss;
  ss << s;
  long long int x;
  ss >> x;
  return x;
}
string tostring(long long int number) {
  stringstream ss;
  ss << number;
  return ss.str();
}
long long int fast_power(long long int a, long long int x) {
  if (x == 0)
    return 1;
  else if (x == 1)
    return a;
  else {
    long long int R = fast_power(a, x >> 1);
    if (!(x & 1))
      return R * R;
    else
      return R * a * R;
  }
}
int main() {
  int n, w, ansmax = INT_MIN, ansmin = INT_MAX, sum = 0, max_people, min_people;
  cin >> n >> w;
  long long int a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    sum += a[i];
    ansmax = max(ansmax, sum);
    ansmin = min(ansmin, sum);
  }
  if (ansmax <= 0) {
    max_people = w;
  } else {
    max_people = w - ansmax;
  }
  if (ansmin < 0) {
    min_people = (-1) * ansmin;
  } else {
    min_people = 0;
  }
  if (min_people < 0 || max_people > w || max_people < min_people) {
    cout << 0;
  } else {
    cout << max_people - min_people + 1;
  }
}
