#include <bits/stdc++.h>
int main() {
  std::iostream::sync_with_stdio(false);
  long long N, W;
  std::cin >> N >> W;
  long long current = 0;
  long long maximum = LLONG_MIN, minimum = LLONG_MAX;
  long long temp;
  for (int i = 0; i < N; ++i) {
    std::cin >> temp;
    current += temp;
    maximum = std::max(maximum, current);
    minimum = std::min(minimum, current);
  }
  long long maxBound = W - maximum;
  long long minBound = 0;
  if (minimum < 0) {
    minBound = abs(minimum);
  }
  if (maximum < 0) {
    maxBound = W;
  }
  if (minBound > W || maxBound < 0 || minBound > maxBound) {
    std::cout << 0 << std::endl;
  } else {
    std::cout << maxBound - minBound + 1 << std::endl;
    ;
  }
  return 0;
}
