import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int X = sc.nextInt();
        int[] L = new int[N+1];
        L[0] = 0;
        for(int i = 1; i < N+1; i++) {
            L[i] = sc.nextInt();
        }
        sc.close();

        System.out.println(Bounding(N+1, X, L, 0, 0));
    }
    public static int Bounding(int N, int X, int[] L, int index, int sum) {
        if (N <= index) {
            return 0;
        }
        if (sum + L[index] <= X) {
            return 1 + Bounding(N, X, L, index + 1, sum + L[index]);
        }
        return 0;
    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int X = sc.nextInt();
        int[] L = new int[N+1];
        L[0] = 0;
        for(int i = 1; i < N+1; i++) {
            L[i] = sc.nextInt();
        }
        sc.close();

        System.out.println(Bounding(N+1, X, L, 0, 0));
    }
    public static int Bounding(int N, int X, int[] L, int index, int sum) {
        if (N <= index) {
            return 0;
        }
        if (sum + L[index] <= X) {
            return 1 + Bounding(N, X, L, index + 1, sum + L[index]);
        }
        return 0;
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int X = sc.nextInt();
        int[] L = new int[N+1];
        L[0] = 0;
        for(int i = 1; i < N+1; i++) {
            L[i] = sc.nextInt();
        }
        sc.close();

        System.out.println(Bounding(N+1, X, L, 0, 0));
    } main {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int X = sc.nextInt();
        int[] L = new int[N+1];
        L[0] = 0;
        for(int i = 1; i < N+1; i++) {
            L[i] = sc.nextInt();
        }
        sc.close();

        System.out.println(Bounding(N+1, X, L, 0, 0));
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc int X = sc.nextInt(); X sc.nextInt() sc.nextInt sc int[] L = new int[N+1]; L new int[N+1] N+1 N 1 L[0] = 0 L[0] L 0 0 for(int i = 1; i < N+1; i++) {
            L[i] = sc.nextInt();
        } int i = 1; int i = 1; i 1 i < N+1 i N+1 N 1 i++ i++ i {
            L[i] = sc.nextInt();
        } {
            L[i] = sc.nextInt();
        } L[i] = sc.nextInt() L[i] L i sc.nextInt() sc.nextInt sc sc.close() sc.close sc System.out.println(Bounding(N+1, X, L, 0, 0)) System.out.println System.out System System.out Bounding(N+1, X, L, 0, 0) Bounding N+1 N 1 X L 0 0 String[] args args public static int Bounding(int N, int X, int[] L, int index, int sum) {
        if (N <= index) {
            return 0;
        }
        if (sum + L[index] <= X) {
            return 1 + Bounding(N, X, L, index + 1, sum + L[index]);
        }
        return 0;
    } Bounding {
        if (N <= index) {
            return 0;
        }
        if (sum + L[index] <= X) {
            return 1 + Bounding(N, X, L, index + 1, sum + L[index]);
        }
        return 0;
    } if (N <= index) {
            return 0;
        } N <= index N index {
            return 0;
        } return 0; 0 if (sum + L[index] <= X) {
            return 1 + Bounding(N, X, L, index + 1, sum + L[index]);
        } sum + L[index] <= X sum + L[index] sum L[index] L index X {
            return 1 + Bounding(N, X, L, index + 1, sum + L[index]);
        } return 1 + Bounding(N, X, L, index + 1, sum + L[index]); 1 + Bounding(N, X, L, index + 1, sum + L[index]) 1 Bounding(N, X, L, index + 1, sum + L[index]) Bounding N X L index + 1 index 1 sum + L[index] sum L[index] L index return 0; 0 int N N int X X int[] L L int index index int sum sum public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int X = sc.nextInt();
        int[] L = new int[N+1];
        L[0] = 0;
        for(int i = 1; i < N+1; i++) {
            L[i] = sc.nextInt();
        }
        sc.close();

        System.out.println(Bounding(N+1, X, L, 0, 0));
    }
    public static int Bounding(int N, int X, int[] L, int index, int sum) {
        if (N <= index) {
            return 0;
        }
        if (sum + L[index] <= X) {
            return 1 + Bounding(N, X, L, index + 1, sum + L[index]);
        }
        return 0;
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int X = sc.nextInt();
        int[] L = new int[N+1];
        L[0] = 0;
        for(int i = 1; i < N+1; i++) {
            L[i] = sc.nextInt();
        }
        sc.close();

        System.out.println(Bounding(N+1, X, L, 0, 0));
    }
    public static int Bounding(int N, int X, int[] L, int index, int sum) {
        if (N <= index) {
            return 0;
        }
        if (sum + L[index] <= X) {
            return 1 + Bounding(N, X, L, index + 1, sum + L[index]);
        }
        return 0;
    }
} Main
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int X = sc.nextInt();
        int[] L = new int[N+1];
        L[0] = 0;
        for(int i = 1; i < N+1; i++) {
            L[i] = sc.nextInt();
        }
        sc.close();

        System.out.println(Bounding(N+1, X, L, 0, 0));
    }
    public static int Bounding(int N, int X, int[] L, int index, int sum) {
        if (N <= index) {
            return 0;
        }
        if (sum + L[index] <= X) {
            return 1 + Bounding(N, X, L, index + 1, sum + L[index]);
        }
        return 0;
    }
}
