AIOC Banner

Problem: Academic Espionage

Want to try solving this problem? You can submit your code online if you log in or register.


Academic Espionage

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.

Input

The input shall consist of sequence of lines. Each line shall consist of a single lower case character. The character shall be one of

You are guaranteed that, at any time, at least as many magicians have entered the building as have left. You are guaranteed that precisely one x line will be present, and that it will be the last line of the input.

Output

Your program shall output a single integer giving the number of magicians remaining in the building at the end of the week.

Sample Input 1

i
o
i
i
o
i
o
o
x

Sample Output 1

0

Sample Input 2

i
o
i
i
o
i
i
o
x

Sample Output 2

2

Scoring

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.

 


Privacy statement
© Australian Mathematics Trust 2001-2019

Contact: training@orac.amt.edu.au
Page generated: 24 May 2019,  3:20am AEST