Input File: acadin.txt
Output File: acadout.txt
Time Limit: 0.333 second
The Department of Magicians at Miskatonic University has been doing well of late. The students are happy working long hours and are doing remarkably well on their exams. The Department of Computer Science has always been a bit nervous about the magicians, and suspects they are up to no good - casting spells to improve their students' study habits. Of course, such spells can only be cast at midnight on Sundays.
The computer scientists daren't go into the building - all manner of spooky things are rumoured about the dark halls of Crowley Memorial Building where the magicians do their work. However, they can watch the entrance to the building from a safe distance using binoculars, and hence observe magicians entering and leaving the building. They know the building is empty each Monday morning at 9am, as all the magicians attend a university council meeting in another building.
As a student in the Computer Science department, your help has been enlisted to find out how many magicians remain in the building in the dead of Sunday night. Your spies on the rooftop let you know each time a magician enters the building and each time a magician leaves the building. You need to write a program to calculate the number of magicians remaining in the building at the end of the week.
You know that the building is initially empty, and that you observe every entry and exit from the building - the magicians can't teleport in or out, or clone each other.
The input shall consist of sequence of lines. Each line shall consist of a single lower case character. The character shall be one of
i: indicating a magician has gone in to the building.
o: indicating a magician has come out of the building.
x: indicating the end of the week (and hence the input).
xline will be present, and that it will be the last line of the input.
Your program shall output a single integer giving the number of magicians remaining in the building at the end of the week.
i o i i o i o o x
i o i i o i i o x
For each test case, your program shall be awarded 100% of the marks if it outputs the correct number of magicians remaining in the building at the end of the week, and 0% otherwise.