#include <bits/stdc++.h>
using namespace std;
const long long INF = 0x3f3f3f3f;
const long long inf = 0x7fffffff;
const double eps = 1e-8;
const int maxn = 1e6 + 10;
const int N = 510;
const long long mod = 1e9 + 7;
const long long MOD = 1e9;
long long sum[maxn];
long long a[maxn];
void solve() {
  int n, m;
  while (cin >> n >> m) {
    for (int i = 1; i <= n; i++) {
      cin >> a[i];
      sum[i] = sum[i - 1] + a[i];
    }
    long long l = 0, r = m;
    for (int i = 1; i <= n; i++) {
      r = min(r, m - sum[i]);
      l = max(l, 0 - sum[i]);
    }
    cout << max(0ll, r - l + 1) << endl;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  solve();
  return 0;
}
