#include <bits/stdc++.h>
using namespace std;
int n, m;
int a[1010];
int main() {
  while (~scanf("%d%d", &n, &m)) {
    int sum = 0, minn, maxx;
    minn = 0x3f3f3f3f;
    maxx = -0x3f3f3f3f;
    for (int i = 0; i < n; i++) {
      scanf("%d", &a[i]);
      sum += a[i];
      minn = min(sum, minn);
      maxx = max(sum, maxx);
    }
    int flag = 0;
    if (minn < -m || maxx > m) flag = 1;
    if (minn < 0 && maxx > 0 && maxx - minn > m) flag = 1;
    if (flag)
      printf("0\n");
    else {
      if (maxx <= 0 && minn <= 0)
        printf("%d\n", m - abs(minn) + 1);
      else if (maxx >= 0 && minn <= 0)
        printf("%d\n", m - abs(minn) - maxx + 1);
      else
        printf("%d\n", m - maxx + 1);
    }
  }
}
