#include <bits/stdc++.h>
using namespace std;
const int maxn = 1010;
int s[maxn];
int n, w;
int check(int st) {
  for (int i = 1; i <= n; i++) {
    st += s[i];
    if (st < 0) return 2;
    if (st > w) return 0;
  }
  return 1;
}
int BS1() {
  int l = 0, r = w;
  while (r - l > 1) {
    int mid = (l + r) >> 1;
    int k = check(mid);
    if (k == 2) {
      l = mid;
    } else if (k == 1) {
      r = mid;
    } else {
      r = mid;
    }
  }
  if (check(l) == 1)
    return l;
  else if (check(r) == 1)
    return r;
  return -1;
}
int BS2() {
  int l = 0, r = w;
  while (r - l > 1) {
    int mid = (l + r) >> 1;
    int k = check(mid);
    if (k == 1) {
      l = mid;
    } else if (k == 2) {
      l = mid;
    } else {
      r = mid;
    }
  }
  if (check(r) == 1)
    return r;
  else if (check(l) == 1)
    return l;
  return -1;
}
int main() {
  scanf("%d%d", &n, &w);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &s[i]);
    if (abs(s[i]) > w) {
      printf("0\n");
      return 0;
    }
  }
  int minn = BS1();
  int maxx = BS2();
  if (minn == -1 || maxx == -1)
    printf("0\n");
  else
    printf("%d\n", max(maxx - minn + 1, 0));
  return 0;
}
