Problem Description
Mice are lazy. But if you think about it, lazy people get more things done than those who laborously do things. Such as trying to encrypt a string. Others will take a pen and paper and slowly work though the steps to encrypt it. But Squeaky Mouse will create a program to do the job for him.
So, as it seems, Squeaky has found a huge stash of cheese, and he wants to tell his best friend Squealy about it. As this is a top-secret mission, Squeaky uses a custom method to encrypt his message. Since other advanced encryption methods are hard to understand and usually comes with a bunch if Wikipedia-ish gibberish, he will derive his encryption method from the simple ROT-13 method.
ROT13 ("rotate by 13 places", sometimes hyphenated ROT-13) is a simple letter substitution cipher that replaces a letter with the letter 13 letters after it in the alphabet. ROT13 is an example of the Caesar cipher, developed in ancient Rome.
~ Wikipedia
So A gets replaced by N and N gets replaced by A, and so on.
Squeaky will supply the message in chunks, and occasionally, you will be asked to encrypt the message so far using ROT-13 encryption.
As the resulting encrypted message may be very long, you will convert each character to a number (A = 1, B = 2, ..., Z = 26) and output the sum of all the numbers.
Input
There is only one line. It will be in this format:
<char1>[length1][!]<char2>[length2][!]...<charn>[lengthn][!]
"<>" denotes a required field, "[]" denotes an optional field.
char is a single lowercase character from a to z.
length is a integer which is the number of copies of char to add to the back of the message string. If it is not specified, it means only one copy of char is added to the message string. length will be at most 1000000.
An exclamation mark (!) denotes that ROT-13 encryption should be applied onto the whole message so far.
Examples are below.
Output
The output should contain exactly one integer, the sum of all the numbers after converting each character to a number.
Limits
Let L be the length of the input string.
0 < L ≤ 106 for all subtasks.
Subtask 1 (10%): length will never be specified; there will be no exclamation marks.
Subtask 2 (30%): length will never be specified.
Subtask 3 (20%): there will be no exclamation marks.
Subtask 4 (40%): no further restructions.
Subtask 5 (0%): Sample
Sample Input 1
ab3!c!d4t!
Sample Output 1
137
Sample Input 2 (satisfies subtask 2)
ter!hello!p
Sample Output 2
150