#include <bits/stdc++.h>
using namespace std;
int n;
int w, a[1000];
int main() {
  scanf("%d %d", &n, &w);
  int minv = 2000000000;
  int maxv = -2000000000;
  int sum = 0;
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    sum += a[i];
    if (sum > maxv) maxv = sum;
    if (sum < minv) minv = sum;
  }
  if (maxv > 0 && maxv > w) {
    printf("0\n");
    return 0;
  }
  if (minv < 0 && -minv > w) {
    printf("0\n");
    return 0;
  }
  int l = max(0, -minv);
  int r = 0;
  if (maxv > 0)
    r = w - maxv;
  else
    r = w;
  if (l > r) {
    printf("0\n");
    return 0;
  }
  int cnt = r;
  for (int i = 0; i < n; i++) {
    cnt += a[i];
    if (cnt < 0 || cnt > w) {
      printf("0\n");
      return 0;
    }
  }
  printf("%d\n", r - l + 1);
  return 0;
}
