Barge#1588

Barge

1 second
64 megabytes
Easy

A barge has cargo compartments. Each compartment can hold several barrels of one of types of fuel. A barrel can be removed from a compartment only if all barrels placed after it in that compartment have already been removed. Thus, at any moment, in each non-empty compartment, there is exactly one barrel that can be removed without disturbing the others. We will call such barrels the extreme ones.

Initially, the barge is empty. Then, it consecutively passes through docks. At each dock, a barrel with a certain type of fuel can be loaded into a specific compartment, or the extreme barrel from a compartment can be unloaded. However, if the specified compartment is empty, or if the unloaded barrel does not have the expected type of fuel, an error should be recorded. If more than barrels are loaded onto the barge at any moment, or if the barge is not empty after passing through all docks, an error should also be recorded. You are required to output either the maximum number of barrels that were simultaneously on the barge or record an error.

Input

The first line contains three integers , , and (1 \leq N, K, P \leq 100000). The next lines describe an action performed at each dock. If loading occurs, the line has the form , where is the number of the compartment the barrel is placed into, and is the type of fuel. If unloading occurs, the line has the form , where is the number of the compartment from which the barrel is removed, and is the expected type of fuel.

Output

Output a single integer equal to the desired maximum in case the barge passes the route without errors, or output Error otherwise.

Examples

Example 1

Loading
Loading