All problems

The Clean Data Streak

hardPythonData CleaningLoops

Selby Instruments ships a data logger, and after every fault report the support team asks the same question: how long did the device manage to run cleanly before it stumbled? The log holds one line per reading, and a reading that failed is written as ERR. What matters is not how many good readings there were altogether but how many arrived in an unbroken row — a device alternating good and bad readings is broken in a way that a device with one long clean spell is not.

Task: Print the length of the longest unbroken run of readings that are not ERR.

Input

The first line holds one integer n, how many log lines follow. Each of the next n lines holds either a reading as a plain number or the exact text ERR. A log may contain no failures at all, and it may contain nothing but failures.

Output

One line holding a single whole number: the length of the longest unbroken run. Print 0 when every line failed.

Example:

Input:
7
1
2
ERR
3
4
5
ERR

Output:
3

Sign in to solve this problem

Reading problems is free for everyone — solving them (Run, Submit, and tracking what you've solved) needs an account.

Sign in

Discussion

Sign in to join the discussion — reading is open to everyone.

Loading comments…