#include <bits/stdc++.h>
using namespace std;
long long n, w;
long long st, dr;
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n >> w;
  long long k = 0, x;
  st = 0;
  dr = w;
  for (int i = 1; i <= n; ++i) {
    cin >> x;
    k += x;
    st = max(st, -k);
    dr = min(dr, w - k);
  }
  if (st <= dr)
    cout << 1LL * dr - st + 1 << "\n";
  else
    cout << 0 << "\n";
  return 0;
}
