P27183 [AtCoder] JOI 2006 Preliminary Problem 3
提高-
题目描述

Problem Description

A die is placed in the following orientation:

Here, the die used is such that when the top side is $1$ and the south side is $2$, the east side is $3$. Since the sum of opposite faces of the die is always $7$, the invisible faces are the north side $5$, the west side $4$, and the bottom side $6$.

2006-yo-t3-fig_base.png

From this initial configuration, the die is moved according to the instructions. The instructions consist of performing one or more of the following $6$ operations:

2006-yo-t3-fig_east.png

2006-yo-t3-fig_left.png

2006-yo-t3-fig_north.png

2006-yo-t3-fig_right.png

2006-yo-t3-fig_south.png

2006-yo-t3-fig_west.png

The operations North, East, South, and West rotate the die $90$ degrees in the specified direction. The operations Right and Left rotate the die $90$ degrees horizontally while keeping the top and bottom faces unchanged (pay attention to the direction of rotation).

Starting with the number $1$ on the top face in the initial configuration, add the number on the top face after each operation, and output the total sum after all operations have been completed.

The first line of input contains the total number of instructions $n$, followed by $n$ lines each containing one of the instructions "North, East, South, West, Right, Left". It is guaranteed that $n \leq 10,000$.

In the output, print the total sum followed by a newline.


Input Format

None

Output Format

None

Sample Input and Output

Sample Input #1

5
North
North
East
South
West

Sample Output #1

21

Sample Input #2

8
West
North
Left
South
Right
North
Left
East

Sample Output #2

34

Notes/Hints

Sample Explanation 1

- - - - - -

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
5 North North East South West
样例输出
21