#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  ;
  int n, w;
  cin >> n >> w;
  vector<long long> v(n);
  for (int i = 0; i < n; i++) cin >> v[i];
  long long tot = 0, al = 0;
  long long minimum = 1e18, maximum = 0;
  for (int i = 0; i < n; i++) {
    tot += v[i];
    minimum = min(minimum, tot);
    maximum = max(maximum, tot);
  }
  long long left = w - maximum;
  if (minimum < 0) al = abs(minimum);
  if (left < 0 || left < al)
    cout << 0;
  else
    cout << left - al + 1;
}
