#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int_fast64_t n, w;
  cin >> n >> w;
  vector<int_fast64_t> a;
  a.reserve(n);
  copy_n(istream_iterator<int_fast64_t>(cin), n, back_inserter(a));
  int_fast64_t min_w = w + 1;
  int_fast64_t l = 0, r = w + 1;
  for (int_fast64_t i = 0; min_w && i < n; ++i) {
    l += a[i];
    l = max((int_fast64_t)0, l);
    l = min(w + 1, l);
    r += a[i];
    r = max((int_fast64_t)0, r);
    r = min(w + 1, r);
    min_w = min(min_w, r - l);
  }
  cout << min_w << endl;
  return 0;
}
