#include <bits/stdc++.h>
using namespace std;
void printAll(int n, ...) {
  if (1) {
    va_list ap;
    va_start(ap, n);
    for (int i = 1; i <= n; i++) cout << va_arg(ap, long long int) << " ";
    cout << endl;
    va_end(ap);
  }
}
template <typename T>
string toString(T n) {
  stringstream ss;
  ss << n;
  string s;
  ss >> s;
  return s;
}
void init() {
  cout << fixed << setprecision(0);
  ios_base::sync_with_stdio(false);
  cin.tie(0);
}
bool isInteger(double n) {
  if (n - (long long int)n == 0)
    return true;
  else
    return false;
}
int main() {
  init();
  long long int i, j, k;
  int n, w;
  cin >> n >> w;
  int x;
  int low = 0;
  int high = w;
  int lowsum = 0;
  int highsum = w;
  for (int i = 0; i < n; i++) {
    cin >> x;
    if (lowsum + x < 0) {
      low -= (lowsum + x);
      lowsum = 0;
    } else
      lowsum += x;
    if (highsum + x > w) {
      high = high + (w - highsum - x);
      highsum = w;
    } else
      highsum += x;
  }
  high < low ? cout << 0 << endl : cout << high - low + 1 << endl;
  return 0;
}
