#include <bits/stdc++.h>
using namespace std;
long long solve() {
  long long n, w;
  cin >> n >> w;
  long long a, x = 0, y = 0, s = 0;
  for (long long i = 0; i < n; i++) {
    cin >> a;
    s += a;
    x = min(x, s);
    y = max(y, s);
  }
  long long b = w - y, c = -x;
  if (b < 0 || c > w) return cout << 0, 0;
  ;
  long long d = b - c + 1;
  if (d < 0) d = 0;
  cout << d;
  return 0;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  long long t = 1;
  while (t--) {
    solve();
    cout << "\n";
  }
  return 0;
}
