#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, w, a, b, mi, ma;
  cin >> n >> w;
  b = 0;
  mi = 0;
  ma = 0;
  for (long long int i = 0; i < n; i++) {
    cin >> a;
    b += a;
    if (b < mi) mi = b;
    if (b > ma) ma = b;
  }
  ma = w - ma;
  mi = abs(mi);
  if (mi > ma || ma < 0)
    cout << "0";
  else
    cout << ma - mi + 1;
}
