#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MAX_ORDER_LENGTH 6
#define END_LOOP		 0

typedef unsigned char   U1;
typedef unsigned short  U2;
typedef unsigned long   U4;
typedef signed   char   S1;
typedef signed   short  S2;
typedef signed   long   S4;

struct Dice {
	U1 u1Top;
	U1 u1South;
	U1 u1East;
	U1 u1North;
	U1 u1West;
	U1 u1Bottom;
};

/********************************************************************************/
/* 関数名   | initData                                                          */
/* 戻り値   | 無し                                                              */
/* 備考     | 無し                                                              */
/********************************************************************************/
void initData(struct Dice *stDice)
{
	stDice->u1Top    = (U1)1;
	stDice->u1South	 = (U1)2;
	stDice->u1East   = (U1)3;
	stDice->u1North  = (U1)5;
	stDice->u1West   = (U1)4;
	stDice->u1Bottom = (U1)6;
}

/********************************************************************************/
/* 関数名   | chngDice                                                          */
/* 戻り値   | 無し                                                              */
/* 備考     | 無し                                                              */
/********************************************************************************/
void chngDice(struct Dice *stDice,char *chString)
{
    U1 u1TmpVal;
	if(strcmp(chString,"North") == 0)
	{
		u1TmpVal        =   stDice->u1Top;
		stDice->u1Top   =   stDice->u1South;
		stDice->u1South =   stDice->u1Bottom;
		stDice->u1Bottom=   stDice->u1North;
		stDice->u1North =   u1TmpVal;
	}
	else if(strcmp(chString,"South") == 0)
	{
		u1TmpVal        =   stDice->u1Top;
		stDice->u1Top   =   stDice->u1North;
		stDice->u1North =   stDice->u1Bottom;
		stDice->u1Bottom=   stDice->u1South;
		stDice->u1South =   u1TmpVal;
	}
	else if(strcmp(chString,"West") == 0)
	{
		u1TmpVal        =   stDice->u1Top;
		stDice->u1Top   =   stDice->u1East;
		stDice->u1East  =   stDice->u1Bottom;
		stDice->u1Bottom=   stDice->u1West;
		stDice->u1West  =   u1TmpVal;
	}
	else if(strcmp(chString,"East") == 0)
	{
		u1TmpVal        =   stDice->u1Top;
		stDice->u1Top   =   stDice->u1West;
		stDice->u1West  =   stDice->u1Bottom;
		stDice->u1Bottom=   stDice->u1East;
		stDice->u1East  =   u1TmpVal;
	}
	else if(strcmp(chString,"Left") == 0)
	{
		u1TmpVal        =   stDice->u1South;
		stDice->u1South =   stDice->u1West;
		stDice->u1West  =   stDice->u1North;
		stDice->u1North =   stDice->u1East;
		stDice->u1East  =   u1TmpVal;
	}
	else if(strcmp(chString,"Right") == 0)
	{
		u1TmpVal        =   stDice->u1South;
		stDice->u1South =   stDice->u1East;
		stDice->u1East  =   stDice->u1North;
		stDice->u1North =   stDice->u1West;
		stDice->u1West  =   u1TmpVal;
	}
}

/********************************************************************************/
/* 関数名   | main                                                              */
/* 引数     | 無し                                                              */
/* 戻り値   | 無し                                                              */
/* 備考     | 無し                                                              */
/********************************************************************************/
int main(void)
{
	struct Dice stDice;
	U2 u2NumOrder;
	U2 u2CntOrder;
	U2 u2DiceSum;
	char chString[MAX_ORDER_LENGTH];

	while (1)
	{
		scanf("%d", &u2NumOrder);
		if (u2NumOrder == (U2)END_LOOP)
		{
			break;
		}
		initData(&stDice);
		u2DiceSum = 1;
		for (u2CntOrder = 0; u2CntOrder < u2NumOrder; u2CntOrder++)
		{
			scanf("%s", chString);
			chngDice(&stDice,chString);
			u2DiceSum += stDice.u1Top;
		}
		printf("%d\n",u2DiceSum);
	}
}



Measured memory_bytes: 1972