#include <bits/stdc++.h>
using namespace std;
const int N = 1e3 + 7, INF = 1e9 + 7;
int n, w;
int a[N];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n >> w;
  for (int i = 0; i < n; ++i) cin >> a[i];
  int dmax = a[0];
  int dmin = a[0];
  for (int i = 1; i < n; ++i) {
    a[i] += a[i - 1];
    dmax = max(dmax, a[i]);
    dmin = min(dmin, a[i]);
  }
  int l = max(0, -dmin);
  int r = min(w, w - dmax);
  if (r < l)
    cout << 0;
  else
    cout << r - l + 1;
  return 0;
}
