Training Site

# Counting Kiwi

Input: Standard Input (stdin)
Output: Standard Output (stdout)
Memory limit: 100 megabytes
Time limit: 1.0 seconds

Doc workers at a local Kiwi sanctuary have asked for your help to build a program that estimates the number of Kiwis in a sanctuary at any one time.

• When new Kiwi are released into the sanctuary, your program will receive a message of the form RELEASED R where R is the number of Kiwis released.
• Your program will also receive messages of the form DECEASED D where D is the number of Kiwi who recently passed away.
• If your program receives the message BREED! then 40% of the Kiwis currently in the sanctuary will lay an egg. From these eggs, 25% will successfully hatch into new Kiwi and be added to the sanctuary.
• When your program receives the message END, output the number of kiwis in the sanctuary and terminate the program.

## Input

The first line of input will contain a number $N$, the number of Kiwi originally in the sanctuary.

The $N$ lines that follow will each contain one of the above messages in any order. These messages finish when you receive the END message.

## Output

The number of Kiwi in the sanctuary when the program ends.

• Subtask 1 (50%) You will only receive RELEASED and DECEASED messages (i.e. focus on the first sample below and ignore the breed message).
• Subtask 2 (50%) The full solution (i.e. including the breed message).

## Hints

• You canâ€™t ever have half a Kiwi or half an egg! (i.e. use integer division)
• You will never have negative Kiwi in your sanctuary.
• $N$ is always less than or equal 1000.

Sample 2 Explanation: Start with 10. Two die leaving 8, then 5 are released giving 13. With 3 more dead we have 10 then they breed. 40% of 10 is 4, then 25% of 4 is 1, so add 1 to 10 to get 11.

• ### Sample Input 1

2
RELEASED 3
DECEASED 4
END


### Sample Output 1

1

• ### Sample Input 2

10
DECEASED 2
RELEASED 5
DECEASED 3
BREED!
END


### Sample Output 2

11