408706: GYM103269 C Abhilash's Dog
Description
Abhilash's dog Brian woke up late today, and there's only $$$m$$$ minutes left until his first class at Doge University starts! He needs to do many tasks before the first class starts. Sadly, Brian will probably not be able to finish all of his tasks. Brian is very efficient however, and can start the next task immediately after the previous, and can join class on Zoom at any point. This means that if Brian can finish a task just as class is about to start at time $$$m$$$, that task can be done. Given that he must do $$$n$$$ tasks in order, where each task $$$i$$$ takes $$$t_i$$$ minutes to complete, determine exactly how many tasks Brian can finish before his first class starts!
InputThe first line of the input contains $$$m (0 \le m \le 10^8)$$$, the number of minutes left until Brian's first class.
The next line of the input will contain $$$n (1 \le n \le 10^3)$$$, the number of tasks Brian needs to do.
The next $$$n$$$ lines of the input will each contain an integer $$$t_i (1 \le t_i \le 10^5)$$$, the amount of time it takes Brian to complete the $$$i^{th}$$$ task.
OutputA single integer, the number of tasks Brian can fully complete before his first class starts. If Brian can only partially finish a task, that does not count.
ExamplesInput5 4 1 2 3 4Output
2Input
0 4 1 2 3 4Output
0Input
10 4 1 2 3 4Output
4