#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <string.h>

//#define __DEBUG__

class Dice {

	private:
		int iNS[4];
		int iEW[4];

	public:
		Dice( int v1, int v2, int v3, int v4, int v5, int v6 ) {
			iNS[0] = v1;
			iNS[1] = v2;
			iNS[2] = v6;
			iNS[3] = v5;

			iEW[0] = v1;
			iEW[1] = v3;
			iEW[2] = v6;
			iEW[3] = v4;

#ifdef __DEBUG__
			printf("NS[%d %d %d %d]\n", iNS[0], iNS[1], iNS[2], iNS[3]);
			printf("EW[%d %d %d %d]\n", iEW[0], iEW[1], iEW[2], iEW[3]);
#endif
		}

		void rotateN() {
			int iTmp = iNS[0];
			iNS[0] = iNS[1];
			iNS[1] = iNS[2];
			iNS[2] = iNS[3];
			iNS[3] = iTmp;

			iEW[0] = iNS[0];
			iEW[2] = iNS[2];

#ifdef __DEBUG__
			printf("NS[%d %d %d %d]\n", iNS[0], iNS[1], iNS[2], iNS[3]);
			printf("EW[%d %d %d %d]\n", iEW[0], iEW[1], iEW[2], iEW[3]);
#endif
		}

		void rotateS() {
			int iTmp = iNS[0];
			iNS[0] = iNS[3];
			iNS[3] = iNS[2];
			iNS[2] = iNS[1];
			iNS[1] = iTmp;

			iEW[0] = iNS[0];
			iEW[2] = iNS[2];

#ifdef __DEBUG__
			printf("NS[%d %d %d %d]\n", iNS[0], iNS[1], iNS[2], iNS[3]);
			printf("EW[%d %d %d %d]\n", iEW[0], iEW[1], iEW[2], iEW[3]);
#endif
		}

		void rotateE() {
			int iTmp = iEW[0];
			iEW[0] = iEW[3];
			iEW[3] = iEW[2];
			iEW[2] = iEW[1];
			iEW[1] = iTmp;

			iNS[0] = iEW[0];
			iNS[2] = iEW[2];

#ifdef __DEBUG__
			printf("NS[%d %d %d %d]\n", iNS[0], iNS[1], iNS[2], iNS[3]);
			printf("EW[%d %d %d %d]\n", iEW[0], iEW[1], iEW[2], iEW[3]);
#endif

		}

		void rotateW() {
			int iTmp = iEW[0];
			iEW[0] = iEW[1];
			iEW[1] = iEW[2];
			iEW[2] = iEW[3];
			iEW[3] = iTmp;

			iNS[0] = iEW[0];
			iNS[2] = iEW[2];

#ifdef __DEBUG__
			printf("NS[%d %d %d %d]\n", iNS[0], iNS[1], iNS[2], iNS[3]);
			printf("EW[%d %d %d %d]\n", iEW[0], iEW[1], iEW[2], iEW[3]);
#endif
		}

		int getTop() {
			return iNS[0];
		}

};

int main(void) {


	int v1, v2, v3, v4, v5, v6;
	char cmd[128];

	v1 = v2 = v3 = v4 = v5 = v6 = 0;

	scanf("%d %d %d %d %d %d", &v1, &v2, &v3, &v4, &v5, &v6 );
	scanf("%s", &cmd );

	Dice *d = new Dice(v1, v2, v3, v4, v5, v6);

	int iLen = strlen(cmd);
	for (int i = 0; i < iLen; i++) {
		char c = cmd[i] & 0xdf;
		switch (c) {
			case 'N':
				d->rotateN();
				break;
			case 'S':
				d->rotateS();
				break;
			case 'E':
				d->rotateE();
				break;
			case 'W':
				d->rotateW();
				break;
			default:
				break;
		}
	}

	printf("%d\n", d->getTop());


}
//	-*- mode: C++ -*-
//	Dice I
//
//		Write a program to simulate rolling a dice, which can be constructed by the following net.
//
//
//
//
//
//
//		As shown in the figures, each face is identified by a different label from 1 to 6.
//
//		Write a program which reads integers assigned to each face identified by the label and a sequence of commands to roll the dice, and prints the integer on the top face. At the initial state, the dice is located as shown in the above figures.
//
//	Input
//		In the first line, six integers assigned to faces are given in ascending order of their corresponding labels.
//
//		In the second line, a string which represents a sequence of commands, is given. The command is one of 'E', 'N', 'S' and 'W' representing four directions shown in the above figures.
//
//	Output
//		Print the integer which appears on the top face after the simulation.
//
//	Constraints
//		0≤ the integer assigned to a face ≤100
//		0≤ the length of the command ≤100
//	Sample Input 1
//		1 2 4 8 16 32
//		SE
//	Sample Output 1
//		8
//		You are given a dice where 1, 2, 4, 8, 16 are 32 are assigned to a face labeled by 1, 2, ..., 6 respectively. After you roll the dice to the direction S and then to the direction E, you can see 8 on the top face.
//
//
//
//	Sample Input 2
//		1 2 4 8 16 32
//		EESWN
//	Sample Output 2
//		32

#include <iostream>
#include <vector>
#include <string>

const unsigned int	faces	{6};

void	E(std::vector<unsigned int>& dice);
void	N(std::vector<unsigned int>& dice);
void	S(std::vector<unsigned int>& dice);
void	W(std::vector<unsigned int>& dice);

int	main(int	argc,
		 char*	argv[])
{
	std::vector<unsigned int>	dice	{};
	dice.resize(faces, 0);

	for(unsigned int i = 0; i < faces; i++){
		std::cin >> dice[i];
	}

	std::string	commands	{};
	std::cin >> commands;

	for(unsigned int i = 0; i < commands.length(); i++){
		switch(commands[i]){
		case 'E':
			E(dice);
			break;
		case 'N':
			N(dice);
			break;
		case 'S':
			S(dice);
			break;
		case 'W':
			W(dice);
			break;
		default:
			break;
		}
	}

	std::cout << dice[0] << '\n';
    return 0;
}

void	E(std::vector<unsigned int>& dice)
{
	unsigned int	x	= dice[0];
	dice[0]	= dice[3];
	dice[3]	= dice[5];
	dice[5]	= dice[2];
	dice[2]	= x;
}

void	N(std::vector<unsigned int>& dice)
{
	unsigned int	x	= dice[0];
	dice[0]	= dice[1];
	dice[1]	= dice[5];
	dice[5]	= dice[4];
	dice[4]	= x;
}

void	S(std::vector<unsigned int>& dice)
{
	unsigned int	x	= dice[0];
	dice[0]	= dice[4];
	dice[4]	= dice[5];
	dice[5]	= dice[1];
	dice[1]	= x;
}

void	W(std::vector<unsigned int>& dice)
{
	unsigned int	x	= dice[0];
	dice[0]	= dice[2];
	dice[2]	= dice[5];
	dice[5]	= dice[3];
	dice[3]	= x;
}

