#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e3 + 10;
int a[maxn];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, w;
  cin >> n >> w;
  int min1 = 0;
  int max1 = 0;
  int now = 0;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    now += a[i];
    min1 = min(min1, now);
    max1 = max(max1, now);
  }
  if (abs(min1) > w || max1 > w) {
    cout << 0 << '\n';
  } else {
    int xia = abs(min1);
    int shang = w - max1;
    if (xia > shang) {
      cout << 0 << '\n';
    } else {
      cout << shang - xia + 1 << '\n';
    }
  }
}
