#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int sum = 0, mini = 0, maxi = 0, x, n, w, res;
  cin >> n >> w;
  for (int i = 0; i < n; i++) {
    cin >> x;
    sum += x;
    maxi = max(maxi, sum);
    mini = min(mini, sum);
  }
  res = w - maxi + 1 + mini;
  if (res >= 0)
    cout << res;
  else
    cout << 0;
}
