#include <bits/stdc++.h>
using namespace std;
const int maxn = 100010;
long long int stops[maxn];
int main() {
  int n, w;
  while (cin >> n >> w) {
    int l = 0, r = w, sum = 0;
    for (int i = 0; i < n; i++) {
      cin >> stops[i];
      sum += stops[i];
      l = max(l, -sum);
      r = min(r, w - sum);
    }
    if (l <= r)
      cout << r - l + 1 << endl;
    else
      cout << 0 << endl;
  }
  return 0;
}
