#include <bits/stdc++.h>
const int N = 1e5 + 5;
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, w;
  cin >> n >> w;
  int a;
  long long ans = 0;
  long long mn = 0, mx = 0, x = 0, y = 0;
  for (int i = 0; i < n; i++) {
    cin >> a;
    ans += a;
    mn = min(mn, ans);
    mx = max(mx, ans);
  }
  x = -mn;
  y = w - mx;
  if (x > y)
    cout << 0;
  else
    cout << y - x + 1;
}
