The busses in Berland are equipped with a video surveillance system. The system records information about changes in the number of passengers in a bus after stops.

If x is the number of passengers in a bus just before the current bus stop and y is the number of passengers in the bus just after current bus stop, the system records the number y-x. So the system records show how number of passengers changed.

The test run was made for single bus and n bus stops. Thus, the system recorded the sequence of integers a_1, a_2, ..., a_n (exactly one number for each bus stop), where a_i is the record for the bus stop i. The bus stops are numbered from 1 to n in chronological order.

Determine the number of possible ways how many people could be in the bus before the first bus stop, if the bus has a capacity equals to w (that is, at any time in the bus there should be from 0 to w passengers inclusive).

Input

The first line contains two integers n and w (1 ≤ n ≤ 1 000, 1 ≤ w ≤ 10^{9}) — the number of bus stops and the capacity of the bus.

The second line contains a sequence a_1, a_2, ..., a_n (-10^{6} ≤ a_i ≤ 10^{6}), where a_i equals to the number, which has been recorded by the video system after the i-th bus stop.

Output

Print the number of possible ways how many people could be in the bus before the first bus stop, if the bus has a capacity equals to w. If the situation is contradictory (i.e. for any initial number of passengers there will be a contradiction), print 0.

Examples

Input

3 5
2 1 -3


Output

3


Input

2 4
-1 1


Output

4


Input

4 10
2 4 1 2


Output

2

Note

In the first example initially in the bus could be 0, 1 or 2 passengers.

In the second example initially in the bus could be 1, 2, 3 or 4 passengers.

In the third example initially in the bus could be 0 or 1 passenger.
import java.io.*;
import java.util.*;

/**
 * Created by hapsi on 11.10.2016.
 */
public class Main {
    private static class FastScanner {
        private BufferedReader bufferedReader;
        private StringTokenizer stringTokenizer;
        public FastScanner(InputStream inputStream){
            bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
        }
        public String next() {
            while (stringTokenizer == null || !stringTokenizer.hasMoreTokens()){
                try {
                    stringTokenizer = new StringTokenizer(bufferedReader.readLine());
                } catch (IOException ignored){}
            }
            return stringTokenizer.nextToken();
        }
        public int nextInt() {
            return Integer.parseInt(next());
        }
        public long nextLong() {
            return Long.parseLong(next());
        }
        public double nextDouble() {
            return Double.parseDouble(next());
        }
    }

    private static int binarySearch(int []a, int l, int r, int x){
        if (l >= r) return -(l+1);
        int m = (l + r) / 2;
        if (a[m] > x || (a[m] == x && m > 0 && a[m-1] == x))
            return binarySearch(a, l, m, x);
        else if (a[m] < x)
            return binarySearch(a, m + 1, r, x);
        return m;
    }

    private static int nextSearch2(long []a, int l, int r, long x){
        if (l >= r) {
            if (a.length == 1 && a[0] <= x) {
                return 0;
            }
            else if (l - 1 >= 0 && a[l-1] <= x) {
                return l - 1;
            }
            else if (l < a.length && a[l] <= x){
                return l;
            }
            else if(l + 1 < a.length && a[l+1] <= x) {
                return l+1;
            }
            else if (l >= a.length && a[a.length - 1] <= x) {
                return a.length - 1;
            }
            return -1;
        }
        int m = (l + r) / 2;
        if (a[m] > x)
            return nextSearch2(a, l, m, x);
        else if (a[m] < x)
            return nextSearch2(a, m + 1, r, x);
        return m;
    }

    private static int nextSearch(int []a, int l, int r, int x){
        if (l >= r) return l;
        int m = (l + r) / 2;
        if (a[m] > x)
            return nextSearch(a, l, m, x);
        else if (a[m] < x || (m < a.length - 1 && a[m+1] == x))
            return nextSearch(a, m + 1, r, x);
        return m + 1;
    }

    private static int nextSearch(LinkedList<Integer>a, int l, int r, int x){
        if (l >= r) return l;
        int m = (l + r) / 2;
        if (a.get(m) > x)
            return nextSearch(a, l, m, x);
        else if (a.get(m) < x || (m < a.size() - 1 && a.get(m+1) == x))
            return nextSearch(a, m + 1, r, x);
        return m + 1;
    }

    private static int nearestSearch(int []a, int l, int r, int x) {
        if (l >= r) {
            if (a.length == 1) {
                return 0;
            }
            else if (l >= a.length) {
                return a.length - 1;
            }
            else if (l-1 >= 0) {
                int d1 = Math.abs(a[l-1] - x);
                int d2 = Math.abs(a[l] - x);
                if (d1 <= d2) {
                    return l-1;
                }
                return l;
            }
            else {
                return l;
            }
        }
        int m = (l + r) / 2;
        if (a[m] > x || (a[m] == x && m > 0 && a[m-1] == x)) {
            return nearestSearch(a, l, m, x);
        }
        else if (a[m] < x) {
            return nearestSearch(a, m + 1, r, x);
        }
        return m;
    }

    private static int compareStringNumbers(String a, String b){
        if(a.length() > b.length()){
            return 1;
        }
        else if(a.length() < b.length()){
            return -1;
        }
        for(int i=0;i<a.length();i++){
            if(a.charAt(i) > b.charAt(i)){
                return 1;
            }
            else if(a.charAt(i) < b.charAt(i)){
                return -1;
            }
        }
        return 0;
    }

    private static int gcd (int a, int b) {
        if (b == 0) return a;
        return gcd (b, a % b);
    }

    private static List<Integer> dfs(ArrayList<ArrayList<Integer>>a, boolean used[], int v) {
        used[v] = true;
        List<Integer>path = null;
        for (int i = 0; i < a.get(v).size(); i++) {
            if(!used[a.get(v).get(i)]) {
                if (path == null)
                    path = dfs(a, used, a.get(v).get(i));
                else
                    path.addAll(dfs(a, used, a.get(v).get(i)));
            }
        }
        if (path == null) path = new ArrayList<>(1);
        path.add(v);
        return path;
    }

    private static boolean next(int[]a){
        for(int i = a.length-1;i>0;i--){
            for(int j=i-1;j>=0;j--) {
                if (a[i] > a[j]) {
                    int t = a[i];
                    a[i] = a[j];
                    a[j] = t;
                    Arrays.sort(a, j + 1, a.length);
                    return true;
                }
            }
        }
        return false;
    }

    private static class LolStack implements Cloneable {
        private Long a[];
        private int index = -1;
        private long sum = 0;
        public LolStack(){
            a = new Long[100];
        }
        public void push(long x) {
            if (a.length <= index + 1) {
                a = Arrays.copyOf(a, a.length + 20);
            }
            a[++index] = x;
            sum+=x;
        }
        public long pop() {
            sum-=a[index];
            return a[index--];
        }
        public boolean isEmpty(){
            return index < 0;
        }

        public long getSum() {
            return sum;
        }

        @Override
        protected Object clone() throws CloneNotSupportedException {
            LolStack t = (LolStack) super.clone();
            t.a = Arrays.copyOf(a, a.length);
            t.sum = sum;
            t.index = index;
            return t;
        }
    }

    private static class LolQueue {
        int a[];
        int m[];
        int maxSize;
        int top = -1;
        int lower = 0;
        boolean computed = false;
        public LolQueue(int maxSize){
            this.maxSize = maxSize;
            a = new int[maxSize];
            m = new int[maxSize];
        }
        public void push(int x){
            a[++top] = x;
            m[top] = x;
            computed = false;
        }
        public int pop() {
            return a[lower++];
        }
        public int min() {
            if (!computed) {
                for (int i = top - 1; i >= lower; i--) {
                    if (m[i + 1] < m[i]) {
                        m[i] = m[i + 1];
                    }
                }
                computed = true;
            }
            return m[lower];
        }
    }
    @SuppressWarnings("unchecked")
    public static void main(String args[]) throws Exception {
        FastScanner scanner = new FastScanner(System.in);
        PrintWriter printer = new PrintWriter(System.out);
        //scanner = new FastScanner(new FileInputStream("input.txt"));
        //printer = new PrintWriter(new FileOutputStream("output.txt"));

        /*int n = scanner.nextInt();
        int []a = new int[n];
        int []b = new int[n];
        int []c = new int[n];
        //printer.println(Integer.MAX_VALUE);
        //printer.println(Long.MAX_VALUE);
        //printer.println((long)Math.pow(10,10));
        for (int i = 0; i < n; i++) {
            b[i] = scanner.nextInt();
            a[i] = b[i] - 1;
            c[i] = b[i] + 1;
            //printer.print(a[i]+ " ");
        }
        int e = 0;
        for (int i = 0; i < m; i++) {
            //b[i] = scanner.nextLong();
            long b = scanner.nextLong();
            while(a[e] < b) {
                e++;
            }
            long l = e == 0 ? 1 : a[e-1] + 1;
            printer.println((e + 1) + " " + (b - l + 1));
        }*/


        int n = scanner.nextInt(), w = scanner.nextInt();
        int a[] = new int[n];
        int h[] = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = scanner.nextInt();
        }
        int max = Integer.MIN_VALUE;
        int min = Integer.MAX_VALUE;
        for (int i = 0; i < n; i++) {
            h[i] = i == 0 ? a[i] : h[i-1] + a[i];
            if(h[i] > max) max = h[i];
            if(h[i] < min) min = h[i];
            //printer.print(h[i] + " ");
        }
        //printer.println();
        int l = Math.max(0, 0 - min);
        int r = Math.min(w - max, w);
        if (r < 0 || l > w || r < l) {
            printer.println(0);
        }
        else {
            //printer.println(l + " " + r);
            printer.println(Math.max(r - l + 1, 0));
        }
        printer.close();
    }
}

