/*
 * 11a.c
 *
 *  Created on: 2017/05/15
 *      Author: SS-76
 */

#include <stdio.h>
//#define DEBUG
#define DEBUG2


/*8????????????????????±?????????dice????§????????????£?¨?
 a,b,c,d?????\??°?????????????????????????????????e,f,g,h??¨?????????
 ??????????????¢??????????????????????????????????????£????????°??????????????\???????????????*/

typedef struct dice{
	int a ;
	int b ;
	int c ;
	int d ;
	int e ;
	int f ;
	int g ;
	int h ;
}DICE;

void rotateN (DICE *);
void rotateS (DICE *);
void rotateE (DICE *);
void rotateW (DICE *);

int judge (DICE *);

int main(void){

	/*??????????????????????????????*/
	int label[6] = {1,2,3,4,5,6};

	/*??????????????£?¨???¨?????????*/
	DICE TESTDICE = {128,64,32,16,8,4,2,1};

	int i = 0 ;						//???????????°
	char command[101] = {} ;		//??????????????????????????£???????´???????

	/*????????????????????????*/
	for( i = 0 ; i < 6 ; i++){
		scanf("%d",&label[i]);
	}

	/*?????????????????????*/
	scanf("%s", command);

	/*??????????????¢??????*/
	for( i = 0; ( command[i] != '\0' ) && ( i < 102) ; i++){
		switch(command[i]){

			case 'N':
				rotateN(&TESTDICE);
				break;
			case 'S':
				rotateS(&TESTDICE);
				break;
			case 'E':
				rotateE(&TESTDICE);
				break;
			case 'W':
				rotateW(&TESTDICE);
				break;
			default:
				printf("error\n");
				break;
		}
	}

	/*???????????¨???*/

	printf("%d\n" ,label[judge(&TESTDICE)]);




#ifdef DEBUG
	printf("?????????a???%d\n",TESTDICE.a);
	printf("?????????b???%d\n",TESTDICE.b);
	printf("?????????c???%d\n",TESTDICE.c);
	printf("?????????d???%d\n",TESTDICE.d);
	printf("?????????e???%d\n",TESTDICE.e);
	printf("?????????f???%d\n",TESTDICE.f);
	printf("?????????g???%d\n",TESTDICE.g);
	printf("?????????h???%d\n",TESTDICE.h);

#endif




	return 0 ;
}

/*N??????????????¢????????¢??°*/
void rotateN (DICE *dice){
	int i = 0;
	i = dice -> e ;
	dice -> e = dice -> g ;
	dice -> g = dice -> c;
	dice -> c = dice -> a;
	dice -> a = i;

	i = dice -> f ;
	dice -> f = dice -> h ;
	dice -> h = dice -> d;
	dice -> d = dice -> b;
	dice -> b = i;

#ifdef DEBUG
	printf("N?????¢?????????????????????a???%d\n",dice->a);
	printf("?????????b???%d\n",dice->b);
	printf("?????????c???%d\n",dice->c);
	printf("?????????d???%d\n",dice->d);
	printf("?????????e???%d\n",dice->e);
	printf("?????????f???%d\n",dice->f);
	printf("?????????g???%d\n",dice->g);
	printf("?????????h???%d\n",dice->h);
#endif
}

/*S??????????????¢????????¢??°*/
void rotateS (DICE *dice){
	int i = 0;
	i = dice -> e ;
	dice -> e = dice -> a ;
	dice -> a = dice -> c;
	dice -> c = dice -> g;
	dice -> g = i;

	i = dice -> f ;
	dice -> f = dice -> b ;
	dice -> b = dice -> d;
	dice -> d = dice -> h;
	dice -> h = i;

#ifdef DEBUG
	printf("S?????¢?????????????????????a???%d\n",dice->a);
	printf("?????????b???%d\n",dice->b);
	printf("?????????c???%d\n",dice->c);
	printf("?????????d???%d\n",dice->d);
	printf("?????????e???%d\n",dice->e);
	printf("?????????f???%d\n",dice->f);
	printf("?????????g???%d\n",dice->g);
	printf("?????????h???%d\n",dice->h);
#endif
}

/*W??????????????¢????????¢??°*/
void rotateE (DICE *dice){
	int i = 0;
	i = dice -> e ;
	dice -> e = dice -> a ;
	dice -> a = dice -> b;
	dice -> b = dice -> f;
	dice -> f = i;

	i = dice -> g ;
	dice -> g = dice -> c ;
	dice -> c = dice -> d;
	dice -> d = dice -> h;
	dice -> h = i;

#ifdef DEBUG
	printf("E?????¢?????????????????????a???%d\n",dice->a);
	printf("?????????b???%d\n",dice->b);
	printf("?????????c???%d\n",dice->c);
	printf("?????????d???%d\n",dice->d);
	printf("?????????e???%d\n",dice->e);
	printf("?????????f???%d\n",dice->f);
	printf("?????????g???%d\n",dice->g);
	printf("?????????h???%d\n",dice->h);
#endif
}

/*E??????????????¢????????¢??°*/
void rotateW (DICE *dice){
	int i = 0;
	i = dice -> e ;
	dice -> e = dice -> f ;
	dice -> f = dice -> b;
	dice -> b = dice -> a;
	dice -> a = i;

	i = dice -> g ;
	dice -> g = dice -> h ;
	dice -> h = dice -> d;
	dice -> d = dice -> c;
	dice -> c = i;

#ifdef DEBUG
	printf("W?????¢?????????????????????a???%d\n",dice->a);
	printf("?????????b???%d\n",dice->b);
	printf("?????????c???%d\n",dice->c);
	printf("?????????d???%d\n",dice->d);
	printf("?????????e???%d\n",dice->e);
	printf("?????????f???%d\n",dice->f);
	printf("?????????g???%d\n",dice->g);
	printf("?????????h???%d\n",dice->h);
#endif
}

/*abcd???????¨?????????????????????????????????¢??°*/
int judge(DICE *dice){

	int i = 0 ;

	switch( (dice -> a) + ( dice -> b ) + ( dice -> c ) + ( dice -> d )){
		case 240:
			i = 0 ;
			break;
		case 204:
			i = 1 ;
			break;
		case 170:
			i = 2 ;
			break;
		case 85:
			i = 3 ;
			break;
		case 51:
			i = 4 ;
			break;
		case 15:
			i = 5 ;
			break;
		default:
			printf("error\n");
			break;
	}


	return i;
}

Measured memory_bytes: 596