Rocks

Statement

Nikita has a profound collection of rocks, all of which have names. In his spare time, Nikita loves to play with his rocks. He does this by arranging his rocks in a line. He occasionally adds more rocks to the end of the line. Unfortunately, he has so many rocks, that he often forgets which rocks he already added. He is not allowed to add a rock that already exists in the line (because they're all unique!). He may also switch the position of two rocks. More importantly, the most fun part is finding the mass of a few consecutive rocks! Obviously, you get the mass of each rock from its name. The name of each rock is unique and consists only of lowercase letters. The longest name Nikita will assign a rock is 100 letters long. The mass of a rock is the sum of the letters in its name, where a = 1, b = 2, c = 3 … z = 26. E.g. rock will have a mass of 47.

Input

You will execute (1 ≤ C ≤ 100 000) commands. There are 5 types of commands, in the following format:
• A R - add rock R to the end of the line, R is a string – the name of the rock, output "Can't add R" if rock R already exists in the line.
• S X Y - swap the position of rocks X and YX and Y are both strings – the name of the two rocks, it is guaranteed that both X and Y exist in the line.
• M X Y - output the mass of rocks in between (inclusive) the rocks X and Y. Both the rocks are guaranteed to exist in the line.
• R X Y - replace rock X with new rock Y – X and Y are both strings. X is guaranteed to exist in the line and Y is guaranteed to not exist in the line.
• N - output the number of rocks currently in the line.
The next C lines contain these 1 lined commands. There will be at most 1 ≤ N ≤ 10 000 rocks in the line at a time. The longest name Nikita will assign a rock is 100 letters long.

Output

Output depends on the commands in input. See the input specification. All output for each command goes on its own separate line.

Example input
```12
A a
A b
A c
M a c
M b c
S a c
M b a
R c d
M d b
A c
A d
N
```
Example output
```6
5
3
6