#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long n, w;
  cin >> n >> w;
  vector<long long> arr(n);
  for (long long i = 0; i < n; ++i) cin >> arr[i];
  vector<long long> runsum(n);
  long long min_elem = arr[0];
  long long max_elem = arr[0];
  vector<long long> run(n);
  long long cur = 0;
  long long tillnow = -1e9;
  for (long long i = 0; i < n; ++i) {
    cur = max(arr[i], cur + arr[i]);
    tillnow = max(tillnow, cur);
  }
  if (tillnow > w) {
    cout << 0 << endl;
    return 0;
  }
  max_elem = tillnow;
  cur = 0;
  tillnow = 1e9;
  for (long long i = 0; i < n; ++i) {
    cur = min(arr[i], cur + arr[i]);
    tillnow = min(tillnow, cur);
  }
  if (tillnow < -w) {
    cout << 0 << endl;
    return 0;
  }
  min_elem = tillnow;
  long long answer = w - max(abs(max_elem), abs(min_elem)) + 1;
  cout << answer << endl;
  return 0;
}
