#t102. 逛商场

逛商场

Shopping at the Mall

Problem Description

Xiaoming is a rather unplanned child. No sooner did he get his pocket money than he took it all to the mall.

Xiaoming's rule is simple: whenever he comes across an item he wants to buy, as long as he can afford it, he buys it and only then moves on; if he cannot afford it, he simply skips it.

After a day of shopping, how many items did Xiaoming actually buy?

Input Format

The input consists of 33 lines:

The 11st line is an integer NN, the number of items Xiaoming wants to buy in the mall (1≤N≤1001 \le N \le 100);

The 22nd line contains NN integers, the prices of the items Xiaoming encounters in order;

The 33rd line is an integer XX, the amount of pocket money Xiaoming starts with, in yuan.

Output Format

Output 11 line containing one integer: the number of items Xiaoming bought.

Sample Input

6
7 5 9 10 7 4
30

Sample Output

4

Sample Explanation

Xiaoming starts with 3030 yuan. The prices he encounters in order are 77, 55, 99, 1010, 77, 44.

  • He sees the 77-yuan item, can afford it, and after buying has 30−7=2330-7=23 yuan left;
  • He sees the 55-yuan item, and after buying has 23−5=1823-5=18 yuan left;
  • He sees the 99-yuan item, and after buying has 18−9=918-9=9 yuan left;
  • He sees the 1010-yuan item, but 9<109 < 10, so he cannot afford it and skips it;
  • He sees the 77-yuan item, and after buying has 9−7=29-7=2 yuan left;
  • He sees the 44-yuan item, but 2<42 < 4, so he cannot afford it and skips it.

In the end Xiaoming bought 44 items in total, so the output is 44.

Constraints

  • 1≤N≤1001 \le N \le 100
  • 0≤ai≤1050 \le a_i \le 10^5 (item prices)
  • XX is a non-negative integer; its range is not explicitly restricted, but the input is guaranteed to be valid.