#include <iostream>
using namespace std;
int main()
{
int n, a[105] = {}, x;
int ans = 0;
cin >> n;
for (int i = 0; i < n; i++)
cin >> a[i];
cin >> x;
for (int i = 0; i < n; i++)
{
if (x >= a[i])
{
x -= a[i];
ans++;
}
}
cout << ans;
return 0;
}