#include <bits/stdc++.h>
using namespace std;
int main() {
  int n = 0, m = 0;
  cin >> n >> m;
  long long last = 0;
  long long max0 = 0;
  long long min0 = 0;
  for (int i = 0; i < n; i++) {
    long long x = 0;
    cin >> x;
    last += x;
    max0 = max(max0, last);
    min0 = min(min0, last);
  }
  if (m - max0 + min0 + 1 > 0)
    cout << (m - max0 + min0 + 1) << endl;
  else
    cout << 0 << endl;
  return 0;
}
