#include <bits/stdc++.h>
using LL = long long;
using LD = long double;
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  LL w;
  cin >> n >> w;
  vector<LL> a(n);
  for (auto i = decltype(n){0}; i < (n); i++) cin >> a[i];
  LL min_val = 0, max_val = 0, curr = 0;
  for (auto i = decltype(n){0}; i < (n); i++) {
    curr += a[i];
    max_val = max(max_val, curr);
    min_val = min(min_val, curr);
  }
  LL min_possible = -min_val;
  LL max_possible = w - max_val;
  if (min_possible <= max_possible)
    cout << max_possible - min_possible + 1 << endl;
  else
    cout << 0 << endl;
}
