#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 50;
const long long MAXN = 1e18 + 10;
const int MAX = 1e5 + 10;
const long long mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
const long long INF = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-7;
inline void solve() {
  int n, w;
  scanf("%d", &n);
  scanf("%d", &w);
  int minn = 0, maxn = w;
  bool flag = false;
  for (int i = 0; i < n; ++i) {
    int temp;
    scanf("%d", &temp);
    if (temp < 0) {
      minn += (-temp);
      if (minn > w) flag = true;
      maxn = min(w, maxn - temp);
    } else if (temp > 0) {
      maxn -= temp;
      if (maxn < 0) flag = true;
      minn = max(0, minn - temp);
    }
    if (maxn < minn) flag = true;
  }
  if (flag)
    printf("0\n");
  else
    printf("%d\n", maxn - minn + 1);
  return;
}
int main() {
  int casen = 1;
  while (casen--) {
    solve();
  }
  return 0;
}
