#include <bits/stdc++.h>
using namespace std;
int dx[] = {0, 0, 0, -1, -1, -1, 1, 1, 1};
int dy[] = {0, 1, -1, 0, 1, -1, 0, 1, -1};
long long n, w, ary[300000 + 5], sum[300000 + 5];
int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> w;
  long long min_w = 0, max_w = 0;
  for (int i = 1; i <= n; ++i) {
    cin >> ary[i];
    sum[i] = sum[i - 1] + ary[i];
    max_w = max(max_w, sum[i]);
    min_w = min(min_w, sum[i]);
  }
  long long s = -min_w, e = w - max_w;
  if (s > e) {
    cout << 0;
    return 0;
  }
  cout << e - s + 1;
  return 0;
}
