By Kay Akashi
Japanese alphabets are often more complex than those of English, thus each of them has multiple "strokes". For example, "depression" in Japanese is "鬱" that requires strokes.
Kay has written a sentence in Japanese on his tablet. Now, Kay knows his sentence consists of characters, and -th character has characters.
His tablet has a function called "object eraser" which enables him to delete the last stroke from the last character. After deleting all the strokes in a single character, the character is completely erased.
He says he is going to press the object eraser button times, but is unsure how many characters are going to be completely erased. Tell him the answer.
. . ().
Apologies for unrealistic constraints (no Japanese character requires as many as billion strokes in reality).
The first line of input contains two integers, and . The second line of input contains integers, .
Output a single integer, the number of characters being erased completely.
5 6
3 2 5 2 2
2
The sentence is "ありがとう" (arigatou, meaning "thank you"). After pressing the button times, the last two characters are completely gone, but the third letter remains undeleted, only to transfer "が" to "か".
2 12
7 5
2
"寿司" (sushi, meaning "sushi"). Every character is gone after pressing the button times because the word as a whole consists of strokes.
29 40
12 9 3 3 3 2 2 3 1 2 3 15 14 1 1 1 2 1 3 2 5 2 2 4 5 2 3 2 1
16
"最後までテストケースを確認してくれてありがとうございます。" (well, just use a translator if you're interested).