#include <bits/stdc++.h>
using namespace std;
long long n, w, a, now, Max, Min;
inline long long max(long long a, long long b) {
  if (a > b)
    return a;
  else
    return b;
}
inline long long min(long long a, long long b) {
  if (a < b)
    return a;
  else
    return b;
}
char ch;
long long f;
inline void read(long long &x) {
  x = 0, f = 1;
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  x *= f;
}
int main() {
  read(n);
  read(w);
  now = 0, Max = -(1 << 50), Min = (1 << 50);
  for (long long i = 1; i <= n; i++) {
    read(a);
    now += a;
    Max = max(now, Max);
    Min = min(now, Min);
  }
  Min = max(-Min, 0);
  Max = min(w, w - Max);
  if (Max < Min)
    cout << 0 << endl;
  else
    cout << Max - Min + 1 << endl;
  return 0;
}
