#include <bits/stdc++.h>
using namespace std;
const int N = 1010;
int n, w, a[N];
int main() {
  cin >> n >> w;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int lo = 0, hi = w, n_lo = 0, n_hi = w;
  for (int i = 0; i < n; i++) {
    n_lo += a[i];
    n_hi += a[i];
    if (n_lo > w || n_hi < 0) return cout << 0 << "\n", 0;
    if (n_lo < 0) {
      lo += -n_lo;
      n_lo = 0;
    }
    if (n_hi > w) {
      hi -= n_hi - w;
      n_hi = w;
    }
  }
  cout << (hi - lo + 1) << "\n";
  return 0;
}
