#include <bits/stdc++.h>
using namespace std;
int main() {
int n, x, z = 0;
cin >> n;
int a[n];
for (int i = 0; i < n; i++) {
cin >> a[i];
}
cin >> x;
int n2 = n;
int i = 0;
while (n2 != 0) {
if (x > a[i]) {
z++;
x -= a[i];
}
i++;
n2--;
}
cout << z;
return 0;
}