#include <iostream>
#include <string>

class Dice
{
/*=======================================*/
/*                Public                 */
/*=======================================*/
public:
	/*-----------------------------------*/
	/*           ???????????¢??°              */
	/*-----------------------------------*/

	/* ????????????????????????????????????          */
	/* ????????????????????? 1,2,3,4,5,6 ????????? */
	Dice()
	{
		init(1, 2, 3, 4, 5, 6);
	}
	
	/* ?????°??§?????????????????????????????§??????????????????????????? */
	Dice(int top, int south, int east, int west, int north, int bottom)
	{
		init(top, south, east, west, north, bottom);
	}
	
	/* ?????????????????? */
	~Dice()
	{
	}
	
	void print(void)
	{
		std::cout << "t=" << num[TOP] << std::endl;
		std::cout << "s=" << num[SOUTH] << std::endl;
		std::cout << "e=" << num[EAST] << std::endl;
		std::cout << "w=" << num[WEST] << std::endl;
		std::cout << "n=" << num[NORTH] << std::endl;
		std::cout << "b=" << num[BOTTOM] << std::endl;
		return;
	}
	
	/* ?????´???????????????????????? */
	void roll_north(void)
	{
		rotate(TOP, NORTH, BOTTOM, SOUTH);
		return;
	}

	/* ?????´???????????????????????? */
	void roll_south(void)
	{
		rotate(TOP, SOUTH, BOTTOM, NORTH);
		return;
	}
	
	/* ??±??´???????????????????????? */
	void roll_east(void)
	{
		rotate(TOP, EAST, BOTTOM, WEST);
		return;
	}
	
	/* ?\???´???????????????????????? */
	void roll_west(void)
	{
		rotate(TOP, WEST, BOTTOM, EAST);
		return;
	}

	/* ?????´???????????????????????? */
	void roll_right(void)
	{
		rotate(NORTH, EAST, SOUTH, WEST);
		return;
	}

	/* ?????´???????????????????????? */
	void roll_left(void)
	{
		rotate(NORTH, WEST, SOUTH, EAST);
		return;
	}

	/* ?????¢????????????????????? */
	int get_top(void)
	{
		return num[TOP];
	}

/*=======================================*/
/*                Private                */
/*=======================================*/
private:
	/*-----------------------------------*/
	/*           ?????°??????                */
	/*-----------------------------------*/
	/* ????????¢???????????? */
	enum Face
	{
		TOP = 0,		/* ?????¢ */
		SOUTH,			/* ?????¢ */
		EAST,			/* ??±??¢ */
		WEST,			/* ?\???¢ */
		NORTH,			/* ?????¢ */
		BOTTOM,			/* ?????¢ */
		NUM_OF_FACES	/* ??¢??° */
	};

	/*-----------------------------------*/
	/*           ???????????¢??°              */
	/*-----------------------------------*/
	/* ??????????????????????????????(?????¢) */
	Dice(const Dice &);
	
	/* ??£??\????????? (?????¢) */
	void operator=(const Dice &);

	/* ????????????????????? */
	void init(int top, int south, int east, int west, int north, int bottom)
	{
		num[TOP]    = top;
		num[SOUTH]  = south;
		num[EAST]   = east;
		num[WEST]   = west;
		num[NORTH]  = north;
		num[BOTTOM] = bottom;
		return;
	}

	/*     num[a]=A,num[b]=B,num[c]=C,num[d]=D */
	/* --> num[a]=D,num[b]=A,num[c]=B,num[d]=C */
	/* ?????????????????????????????????????????§?????????      */
	void rotate(Face a, Face b, Face c, Face d)
	{
		int temp = num[d];
		num[d]   = num[c];
		num[c]   = num[b];
		num[b]   = num[a];
		num[a]   = temp;
		return;
	}

	/*-----------------------------------*/
	/*           ??????????????°              */
	/*-----------------------------------*/
	int num[NUM_OF_FACES];	/* ????????? */
};


void ITP1_11_A(void)
{
	int top, south, east, west, north, bottom;
	std::string commands;
	
	std::cin >> top >> south >> east >> west >> north >> bottom;
	std::cin >> commands;
	
	Dice dice(top, south, east, west, north, bottom);

	int command_length = commands.length();
	for(int i = 0; i < command_length; ++i)
	{
		switch(commands[i])
		{
			case 'N':
				dice.roll_north();
				break;
			case 'S':
				dice.roll_south();
				break;
			case 'E':
				dice.roll_east();
				break;
			case 'W':
				dice.roll_west();
				break;
			default:
				/* ????????\??????????????????????????? */
				break;
		}
	}

	std::cout << dice.get_top() << std::endl;
	
	return;
}

int main(void)
{
	ITP1_11_A();
	return 0;
}

Measured memory_bytes: 3188