Under construction

Still being built. Things may change

Hanging Out on the Terrace

Interview

Time limit1sMemory limit512 MB

Summary
Track how many people are on a terrace with a limit L and count how many enter groups are turned away because they would exceed it.
Level

Easy2 of 10

Topics
Simulation, Implementation
Solved
No attempts yet

Problem

The HiQ office in Stockholm has a pretty nice rooftop terrace, often used for company parties and events such as programming competitions.

Unfortunately, fire safety rules limit the number of people who can be on the terrace at any one time: at most LL people. During a party, people come and go to the terrace, but keeping track of how many people are currently on the terrace is a nuisance. On top of that, people often enter the terrace in groups. If a group wants to enter the terrace but their addition would exceed the fire safety limit, the group goes inside to play ping pong instead.

Your task is to write a program that, given the sizes of the groups that attempted to enter the terrace during a party and when people left the terrace, determines how many times a group was denied entry to the terrace.

Input

The first line of input contains the fire safety limit 1≤L≤2001 \le L \le 200 and the number of events 0≤x≤1000 \le x \le 100.

The next xx lines contain the events. Each event begins with one of the words "enter" or "leave", depending on whether the event describes a group attempting to enter the terrace or a set of people leaving it.
This is followed by an integer 1≤p≤2001 \le p \le 200, the number of people entering or leaving at this time.

The number of people who leave the terrace will never exceed the number of people currently on the terrace.

Output

Output the number of groups that were not allowed to enter the terrace during the party.

Examples1

  1. Example 1

    Input
    4 5
    enter 3
    enter 2
    leave 1
    enter 1
    enter 2
    
    Expected output
    2