#include <bits/stdc++.h>
using namespace std;
long long w, x, maxn = 0, minn = 0, now = 0;
int n;
int main() {
  cin >> n >> w;
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &x);
    now += x;
    if (maxn < now) maxn = now;
    if (minn > now) minn = now;
  }
  if ((maxn - minn) > w) {
    cout << '0' << endl;
  } else {
    cout << (w - (maxn - minn + 1)) + 2 << endl;
  }
  return 0;
}
