You have run out of disk space and decided to delete some of your directories. Before you decide what goes, you look at what your file system holds, and you do that from a command line interface. The interface used in this problem is called MSDOS--, since it is MSDOS with fewer features. The commands of MSDOS-- are as follows.
cd <directory>: <directory> is a relative path to a descendant of the current directory. The command moves the current directory to <directory>. For example, when the current directory is \A\B\ and C\D sits below it, running cd C\D makes the current directory \A\B\C\D\.
cd \: moves the current directory to \, the root of the file system. For example, when the current directory is \A\B\, running cd \ makes the current directory \.
cd ..: when the current directory is not \, moves the current directory to its parent. For example, when the current directory is \A\B\, running cd .. makes the current directory \A\.
cd \<directory>: the same as running cd \ and then cd <directory>.
dir: lists the names of the files and directories that sit directly in the current directory, one name per line. A name is made of lowercase and uppercase letters, digits, and dots (.). Directory names come before file names, and a directory takes a line by itself. A file name is followed by a single space and its size. A listing produced by dir has this format.
HW1
HW1.old
Syllab.pdf 10000
notes.txt 3241
deltree <directory>: <directory> is a relative path to a descendant of the current directory. The command deletes <directory> together with every file and subdirectory below it, freeing that much space. For example, when the current directory is \A\B\ and C\D sits below it, running deltree C\D deletes \A\B\C\D\ and everything below it.
deltree \<directory>: the same as running cd \ and then deltree <directory>.
exit: terminates the command line interface.
A scenario is an exploration, a consistent series of cd and dir commands with their results starting from the root, followed by exactly one deltree command. The exploration does not reveal the whole file system. A directory you never opened with dir may be empty. Given a scenario, find the maximum space its deltree command is guaranteed to free. That is the smallest amount deltree deletes over all file systems consistent with the exploration.
The input holds several independent scenarios. One empty line follows each scenario. The input ends with an exit command. Every command in the input is preceded by a > sign with no space in between, and the result lines a command produces carry no >. The length of a file name does not exceed 50. The input is always correct.
Write the result of the ith scenario as a single integer on the ith line of the output.