#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
int main() {
  int n, w;
  scanf("%d%d", &n, &w);
  int maxx = -0x3f3f3f3f, minn = 0x3f3f3f3f;
  int sum = 0;
  for (int i = 0; i < n; i++) {
    int x;
    scanf("%d", &x);
    sum += x;
    maxx = max(maxx, sum);
    minn = min(minn, sum);
  }
  if (maxx > w || minn < -w || w - maxx < -minn)
    printf("0\n");
  else {
    int t = w;
    int mark = 0;
    if (maxx >= 0) {
      t = w + 1 - maxx;
      mark = 1;
    }
    if (minn <= 0 && mark)
      t = t - (-1 * minn);
    else if (minn <= 0)
      t = t + 1 + minn;
    printf("%d\n", t);
  }
  return 0;
}
