#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, w, ans;
  long int maxsum, minsum, sum;
  cin >> n >> w;
  vector<int> arr(n, 0);
  for (int i = 0; i < n; i++) cin >> arr[i];
  maxsum = minsum = sum = arr[0];
  for (int i = 1; i < n; i++) {
    sum += (long int)arr[i];
    if (sum > maxsum)
      maxsum = sum;
    else if (sum < minsum)
      minsum = sum;
  }
  if (minsum < 0) {
    if (-minsum > w) {
      cout << 0 << "\n";
      return 0;
    }
    if (maxsum > 0) {
      ans = w - maxsum;
      ans += minsum;
      if (ans >= 0)
        cout << ans + 1 << "\n";
      else
        cout << 0 << "\n";
    } else {
      ans = w + minsum;
      cout << ans + 1 << "\n";
    }
  } else {
    ans = w - maxsum;
    if (ans >= 0)
      cout << ans + 1 << "\n";
    else
      cout << 0 << "\n";
  }
  return 0;
}
