#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  while (~scanf("%d%d", &n, &m)) {
    int i, j, maxx = -999999, minn = 999999;
    int flag = 0, a, sum = 0;
    for (i = 0; i < n; i++) {
      scanf("%d", &a);
      sum += a;
      maxx = max(maxx, sum);
      minn = min(minn, sum);
    }
    if (minn < -m || maxx > m) flag = 1;
    if (minn < 0 && maxx > 0 && maxx - minn > m) flag = 1;
    if (flag == 1)
      printf("0\n");
    else {
      int k = m;
      if (minn <= 0) k = m + minn + 1;
      if (maxx >= 0 && minn <= 0)
        k = k - maxx;
      else if (maxx >= 0)
        k = k - maxx + 1;
      printf("%d\n", k);
    }
  }
  return 0;
}
