#include <bits/stdc++.h>
using namespace std;
string Y = "YES\n";
string N = "NO\n";
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t;
  t = 1;
  for (long long i = 0; i < t; i++) {
    long long n, k;
    cin >> n >> k;
    long long arr[n];
    for (long long x = 0; x < n; x++) cin >> arr[x];
    long long lowlev = INT_MAX;
    long long highlev = INT_MIN;
    long long lev = 0;
    for (long long x = 0; x < n; x++) {
      lev += arr[x];
      if (lev > highlev) highlev = lev;
      if (lev < lowlev) lowlev = lev;
    }
    if (lowlev < 0)
      lowlev = 0 - lowlev;
    else
      lowlev = 0;
    if (lowlev > k || highlev > k) {
      cout << 0 << '\n';
      continue;
    }
    if (highlev > 0)
      highlev = k - highlev;
    else
      highlev = k;
    if (lowlev > highlev + 1) {
      cout << 0 << '\n';
      continue;
    }
    cout << highlev - lowlev + 1 << '\n';
  }
  return 0;
}
