#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3;
int main() {
  int n, w, v[10000];
  scanf("%d %lld", &n, &w);
  long long lo = 0, hi = 0, sum = 0;
  for (int i = 0; i < n; i++) {
    scanf("%d", &v[i]);
    sum += v[i];
    lo = min(sum, lo);
    hi = max(sum, hi);
  }
  printf("%lld\n", max((w - hi) + lo + 1, 0LL));
}
