#include <bits/stdc++.h>
using namespace std;
const long long INF = 100000000000000;
int main() {
  int n, w, x;
  cin >> n >> w;
  long long atual = 0, max_st = -INF, min_st = INF;
  for (int i = 0; i < n; i++) {
    cin >> x;
    atual += x;
    if (abs(atual) > w) {
      printf("0\n");
      return 0;
    }
    min_st = min(min_st, atual);
    max_st = max(max_st, atual);
  }
  long long upper_b = (max_st < 0 ? w : w - max_st);
  long long lower_b = (min_st >= 0 ? 0 : -min_st);
  if (upper_b < lower_b)
    printf("0\n");
  else
    printf("%d\n", upper_b - lower_b + 1);
}
