#include <bits/stdc++.h>
using namespace std;
int main() {
  long long N, W;
  cin >> N >> W;
  long long lowest = 0, highest = W;
  long long current = 0, sum = 0;
  while (N--) {
    cin >> current;
    sum += current;
    lowest = max(lowest, -sum);
    highest = min(highest, W - sum);
  }
  cout << max(0ll, highest - lowest + 1) << endl;
  return 0;
}
