#include <bits/stdc++.h>
using namespace std;
long long int prime[1000010] = {0};
vector<long long int> pr;
void sieve() {
  prime[0] = 1;
  prime[1] = 1;
  for (long long int i = 2; i <= sqrt(1000010); i++) {
    if (prime[i] == 0) {
      for (long long int j = i * i; j < 1000010; j += i) {
        prime[j] = 1;
      }
    }
  }
  for (long long int i = 2; i < 1000010; i++) {
    if (!prime[i]) pr.push_back(i);
  }
  return;
}
double pi = 3.141592653589;
long long int a[200100];
long long int pre[200100] = {0};
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int n, w;
  cin >> n >> w;
  for (long long int i = 1; i <= n; i += 1) {
    cin >> a[i];
    pre[i] = pre[i - 1] + a[i];
  }
  long long int mi = 0, ma = 0;
  for (long long int i = 1; i <= n; i += 1) {
    mi = min(mi, pre[i]);
    ma = max(ma, pre[i]);
  }
  long long int ans = (w - ma) + (mi + 1);
  if (ans > w + 1 || ans < 0)
    cout << 0 << endl;
  else
    cout << ans << endl;
}
