#include <bits/stdc++.h>
using namespace std;
const long long INF = 9e18;
const int inf = 2147483647;
long long qpow(long long a, long long b, long long mod) {
  long long r = 1;
  for (; b; b >>= 1) {
    if (b & 1) r = (r * a) % mod;
    a = (a * a) % mod;
  }
  return r;
}
const int N = 1e3 + 5;
int a[N];
void work() {
  int n, w;
  scanf("%d%d", &n, &w);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  int l = 0, r = w;
  int mx = -1;
  while (l <= r) {
    int x0 = (l + r) / 2;
    int x = x0, ok = 0;
    for (int i = 0; i < n; i++) {
      int y = x0 + a[i];
      if (y > w) {
        ok = 1;
        break;
      } else if (y < 0) {
        ok = -1;
        break;
      }
      x0 = y;
    }
    if (!ok) {
      l = x + 1;
      mx = x;
    } else if (ok > 0) {
      r = x - 1;
    } else {
      l = x + 1;
    }
  }
  int mn = -1;
  l = 0, r = w;
  while (l <= r) {
    int x0 = (l + r) / 2;
    int x = x0, ok = 0;
    for (int i = 0; i < n; i++) {
      int y = x0 + a[i];
      if (y > w) {
        ok = 1;
        break;
      } else if (y < 0) {
        ok = -1;
        break;
      }
      x0 = y;
    }
    if (!ok) {
      r = x - 1;
      mn = x;
    } else if (ok > 0) {
      r = x - 1;
    } else {
      l = x + 1;
    }
  }
  if (mx < 0 || mn < 0)
    printf("%d\n", 0);
  else
    printf("%d\n", mx - mn + 1);
}
int main() {
  work();
  return 0;
}
