#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n, w, ma, mi, ans;
  cin >> n >> w;
  vector<long long> a(n);
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
  }
  long long l = 0, r = w + 1;
  while (r - l > 1) {
    long long mid = (r + l) / 2;
    ans = mid;
    for (long long i = 0; i < n; i++) {
      ans += a[i];
      if (ans > w) {
        r = mid;
        break;
      }
    }
    if (r != mid) l = mid;
  }
  ma = l;
  l = -1, r = w;
  while (r - l > 1) {
    long long mid = (r + l) / 2;
    ans = mid;
    for (long long i = 0; i < n; i++) {
      ans += a[i];
      if (ans < 0) {
        l = mid;
        break;
      }
    }
    if (l != mid) r = mid;
  }
  mi = r;
  for (long long j = 0; j < 10; j++) {
    ans = mi;
    long long f = 0;
    for (long long i = 0; i < n; i++) {
      ans += a[i];
      if (ans > w || ans < 0) {
        f = 1;
      }
    }
    if (f)
      mi++;
    else
      break;
  }
  for (long long j = 0; j < 10; j++) {
  }
  if (mi <= ma)
    cout << ma - mi + 1;
  else
    cout << 0;
}
