#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  long long n, w;
  cin >> n >> w;
  long long A[n];
  for (int i = 0; i < n; i++) cin >> A[i];
  int mi = 0, ma = w;
  bool is = false;
  for (int i = n - 1; i > -1; i--) {
    if (i == n - 1) {
      if (A[i] <= 0) {
        mi = abs(A[i]);
        ma = w;
        if (mi <= w and ma > w)
          ma = w;
        else if (mi > w and ma > w) {
          is = true;
          break;
        }
      } else {
        mi = 0;
        ma = w - A[i];
        if (mi < 0 and ma >= 0)
          mi = 0;
        else if (mi < 0 and ma < 0) {
          is = true;
          break;
        }
      }
    } else {
      if (A[i] <= 0) {
        mi += abs(A[i]);
        ma += abs(A[i]);
        if (mi <= w and ma > w)
          ma = w;
        else if (mi > w and ma > w) {
          is = true;
          break;
        }
      } else {
        mi -= abs(A[i]);
        ma -= abs(A[i]);
        if (mi < 0 and ma >= 0)
          mi = 0;
        else if (mi < 0 and ma < 0) {
          is = true;
          break;
        }
      }
    }
  }
  if (is)
    cout << 0 << endl;
  else
    cout << ma - mi + 1;
  return 0;
}
