#include <bits/stdc++.h>
using namespace std;
inline int read() {
  register int x = 0;
  register bool f = 0;
  register char ch = getchar();
  while (!isdigit(ch)) {
    f ^= !(ch ^ '-');
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = (x + (x << 2) << 1) + (ch ^ '0');
    ch = getchar();
  }
  return f ? -x : x;
}
inline void print(int x) {
  register int sc[30] = {0}, tot = 0;
  do {
    sc[++tot] = x % 10;
    x /= 10;
  } while (x);
  while (tot) putchar('0' + sc[tot--]);
}
int n, m, sum, tmp, minn, maxn, ans;
int main() {
  n = read();
  m = read();
  for (register int i = 1; i <= n; i++) {
    tmp = read();
    sum += tmp;
    maxn = (maxn > sum ? maxn : sum);
    minn = (minn < sum ? minn : sum);
  }
  ans = m - maxn - abs(minn) + 1;
  ans = (ans > 0 ? ans : 0);
  printf("%d\n", ans);
  return 0;
}
