#include <bits/stdc++.h>
using namespace std;
long long vis[10000], arr[200005], arr2[100009], ind;
vector<long long> v;
int main() {
  long long n, i, j, start, b, m, k, l, d, up, low, w, sum;
  cin >> n >> w;
  for (i = 1; i <= n; i++) {
    cin >> arr[i];
    if (abs(arr[i]) > w) {
      cout << "0";
      return 0;
    }
  }
  long long curr = 0;
  long long maxpos = 0;
  long long maxneg = 0;
  for (i = 1; i <= n; i++) {
    curr = curr + arr[i];
    if (curr >= 0) {
      maxpos = max(maxpos, curr);
    }
    if (curr <= 0) {
      maxneg = min(maxneg, curr);
    }
  }
  if (maxpos >= 0) {
    up = w - maxpos;
  }
  if (maxneg <= 0) {
    low = -maxneg;
  }
  if (up - low + 1 >= 0 && up >= 0 && low <= w && low >= 0 && up <= w)
    cout << up - low + 1;
  else
    cout << "0";
  return 0;
}
