#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18 + 10, MAX = 2e5 + 1e4, MOD = 1e9 + 7, MAXL = 25;
void OUT(long double o, int x) {
  cout << fixed << setprecision(x) << o;
  return;
}
long long a[MAX];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n, mi = INF, x = 0, ma = -INF, w;
  cin >> n >> w;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    x += a[i];
    mi = min(mi, x);
    ma = max(ma, x);
  }
  long long l = max((long long)0, -mi);
  long long r = w - max((long long)0, ma);
  cout << max(r - l + 1, (long long)0);
  return 0;
}
