B. Nostalgia
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

Aidar, Begimai, and Viktor came to the trial round of the championship.

They saw Scratch in the list of available compilers and remembered how they started learning programming with this language.

For example, during manual testing, it was often unclear what the program was waiting for in terms of input for a particular variable. Therefore, sometimes they would locally add output of the variable name before the input (but would remove it before submitting to the testing system).

The teammates even found several of their submissions on Scratch from those long-ago times in the system.

Now they are curious — how many total characters did they additionally output during local testing compared to the final submission to the system?

Input

The first line contains an integer $$$n$$$ $$$(2 \le n \le 10^5)$$$ — the number of lines in the Scratch program code.

The next $$$n$$$ lines contain one command of the analyzed program.

Commands can be one of the following types:

  • An input request in the format "Ask read_token and wait";
  • Storing the entered information in the variable name in the format "Set name to answer";
  • Assigning the variable name1 the result of the arithmetic operation op on the variables name2 and name3 in the format "Set name1 to name2 op name3";
  • Outputting the value of the variable name to the screen in the format Say name.

It is guaranteed that

  • all variable names consist only of lowercase Latin letters (az) and contain from $$$1$$$ to $$$10$$$ characters;
  • the source code does not contain variables named answer, which is reserved for inputting information into a variable.

It is guaranteed that op can only be one of the following symbols:

  • + — addition;
  • - — subtraction;
  • * — multiplication;
  • / — division.

It is guaranteed that

  • each input request is necessarily accompanied by storing the entered information in a variable;
  • each storage of entered information in a variable necessarily follows an input request.

It is guaranteed that all variables are used in the right side of arithmetic expressions only after their correct initialization.

Output

Output a single integer $$$P$$$ $$$(1 \le P \le 10^9)$$$ — the total number of characters that the teammates output additionally during local testing of this program.

Examples
Input
6
Ask read_token and wait
Set first to answer
Ask read_token and wait
Set second to answer
Set result to first + second
Say result
Output
11
Input
15
Ask read_token and wait
Set a to answer
Ask read_token and wait
Set bb to answer
Set ccc to a * bb
Set dddd to a / bb
Set dddd to ccc + dddd
Say dddd
Ask read_token and wait
Set bb to answer
Ask read_token and wait
Set ccc to answer
Set x to bb * dddd
Set x to ccc - x
Say x
Output
8
Note

First test example

In the program, two input operations are performed:

  • the variable first is entered once — $$$5$$$ additional characters for input;
  • the variable second is entered once — $$$6$$$ additional characters for input.

In total, the teammates output additionally exactly $$$5 + 6 = 11$$$ characters.

Second test example

In the program, four input operations are performed:

  • the variable a is entered once — $$$1$$$ character for input;
  • the variable bb is entered twice — $$$2$$$ characters for input;
  • the variable ccc is entered once — $$$3$$$ characters for input.

In total, the teammates output additionally exactly $$$1 + 2 \cdot 2 + 3 = 8$$$ characters.