#K1916. Pen Refill Counter

    ID: 24621 Type: Default 1000ms 256MiB

Pen Refill Counter

Pen Refill Counter

You are given a pen which can write at most C characters in one go before needing a refill. You have W words to write, where each word's length is the number of characters that will be written.

Whenever writing a word would cause the total number of characters written since the last refill to exceed C, you must refill the pen first and then write the word. If there are any characters written after the last refill, that counts as a final refill.

In mathematical terms, let the pen capacity be \(C\) and the words be \(w_1, w_2, \dots, w_W\), where the length of each word is \(|w_i|\). You simulate the writing as follows:

[ \text{if } \sum_{i=1}^{k} |w_i| > C \text{, then refill before writing } w_{k+1}. ]

Your task is to determine the total number of refills required to write all the words.

inputFormat

The input is given via standard input (stdin) with the following format:

C W
word1
word2
...
wordW

Here, C is an integer representing the maximum number of characters that can be written before a refill is needed, and W is the number of words that follow. Each of the next W lines contains a single word.

outputFormat

Output a single integer to standard output (stdout) — the total number of refills required to write all words.

## sample
10 4
pen
notebook
ink
refill
3