#include <bits/stdc++.h>
using namespace std;
long long int inf = 1e18;
long long int mod = 1e9 + 7;
long long int gcd(long long int a, long long int b) {
  return b == 0 ? a : gcd(b, a % b);
}
int main() {
  long long int t = 1;
  while (t--) {
    long long int n, mx;
    scanf("%lld", &n) + scanf("%lld", &mx);
    long long int mini = inf;
    long long int maxi = -inf;
    long long int sum = 0ll;
    for (long long int i = (long long int)(1); i <= (long long int)(n); i++) {
      long long int num;
      scanf("%lld", &num);
      sum += num;
      mini = min(mini, sum);
      maxi = max(maxi, sum);
    }
    long long int toAdd = -1ll * min(0ll, mini);
    maxi += toAdd;
    maxi = max(maxi, toAdd);
    if (maxi > mx) {
      cout << "0\n";
      continue;
    } else {
      cout << mx - maxi + 1ll << endl;
      continue;
    }
  }
  return 0;
}
