#include <bits/stdc++.h>
using ll = long long;
int main() {
  int n, w;
  std::cin >> n >> w;
  ll minValue = -1;
  ll maxValue = ll(w) + 1;
  ll total = 0;
  for (int i = 0; i < n; ++i) {
    ll v;
    std::cin >> v;
    total += v;
    maxValue = std::min(maxValue, ll(w) - total);
    minValue = std::max(minValue, -total);
  }
  maxValue = std::min(maxValue, ll(w));
  minValue = std::max(minValue, ll(0));
  ll result = maxValue - minValue + 1;
  std::cout << std::max(result, ll(0)) << std::endl;
  return 0;
}
