#include <bits/stdc++.h>
using namespace std;
int n, w;
int main() {
  scanf("%d%d", &n, &w);
  int l = 0, r = w, s = 0, x;
  bool bo = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &x);
    s += x;
    if (s > w || s < -w) {
      bo = 1;
      break;
    }
    if (s == 0)
      continue;
    else if (s > 0 && s <= w)
      r = min(r, w - s);
    else
      l = max(l, -s);
  }
  if (bo || l > r)
    printf("0\n");
  else
    printf("%d\n", r - l + 1);
  return 0;
}
