#include<bits/stdc++.h>
#define int long long
using namespace std;
    int a[150];
    main()
    {
        int n, x;
        cin >> n >> x;
        int suma = 0;
        int m = x;
        int ans = 0;
        for(int i = 1 ; i <= n;i++)
            cin >> a[i];
        //sort(a+1,a+n+1);
        int cnt = 0;
            for(int j = 1 ; j <= n;j++)
            {
                if(x >= a[j]){
                    x -= a[j];
                    cnt++;


                }
                if(x >= a[j] and j == n){
                    cnt--;
                    cout << cnt;
                    return 0;
                }



            }

        cout << cnt;




    }
