#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(NULL);
  long long int r, l, a, n, o = 0, m, k = 0, kmax = -2000000000,
                            kmin = 2000000000;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> a;
    k += a;
    kmax = max(k, kmax);
    kmin = min(k, kmin);
  }
  if (kmax > m) {
    cout << 0;
    return 0;
  }
  if (kmin < -m) {
    cout << 0;
    return 0;
  }
  r = min(m - kmax, m);
  l = max(-kmin, o);
  if (l > r) {
    cout << 0;
    return 0;
  }
  cout << r - l + 1;
}
