A monitoring system records the status of different services.
You are given a sequence of log entries. Each entry is represented as:
<service_name> <status>
where:
For every service, maintain the number of consecutive "error" logs since its last "success" or alert. Whenever a service accumulates 3 consecutive errors, an alert is triggered immediately, and its consecutive error count is reset to 0.
Your task is to determine the total number of alerts generated.
N service1 status1 service2 status2 ... serviceN statusN
Print a single integer — the total number of alerts generated.