#include <iostream>
using namespace std;
#include <stdio.h>
void ushm(char x);
struct sai {
	int dicet[3][2];
	int diceus[2], dicemh[2];
	int dicenow;
};
struct sai a = { { 1, 6, 2, 5, 3, 4 },{ 5, 2 },{ 4, 3 }, 1 };
int main()
{
	int	atai[6], i;
	char houi[101];
	for (i = 0; i < 6; i++) { cin >> atai[i]; }
	cin >> houi;
	for (i = 0; i <= 100 && houi[i] != '\0'; i++) {
		ushm(houi[i]);
	}
	printf("%d\n", atai[a.dicenow - 1]);
	return 0;
}
void ushm(char x)
{
	int now = a.dicenow, nowt, i;
	for (i = 0; i < 3; i++)
	{
		if (a.dicet[i][0] == now)
			nowt = a.dicet[i][1];
		else if (a.dicet[i][1] == now)
			nowt = a.dicet[i][0];
	}
	switch (x) {
	case 'N': a.dicenow = a.diceus[1]; a.diceus[0] = now; a.diceus[1] = nowt; break;
	case 'S': a.dicenow = a.diceus[0]; a.diceus[1] = now; a.diceus[0] = nowt; break;
	case 'W': a.dicenow = a.dicemh[1]; a.dicemh[0] = now; a.dicemh[1] = nowt; break;
	case 'E': a.dicenow = a.dicemh[0]; a.dicemh[1] = now; a.dicemh[0] = nowt; break;
	}
}
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <array>
using namespace std;

#define DEBUG(x) cerr << #x << " = " << x << endl

enum FACE { TOP, FRONT, RIGHT, LEFT, BACK, BOTTOM }; // 1..6
typedef array<int, 6> Dice;

FACE tbl[6][4] = {
  { TOP, BACK, BOTTOM, FRONT },
  { TOP, RIGHT, BOTTOM, LEFT },
  { TOP, FRONT, BOTTOM, BACK },
  { TOP, LEFT, BOTTOM, RIGHT },
  { FRONT, RIGHT, BACK, LEFT },
  { FRONT, LEFT, BACK, RIGHT }
};

enum MOVE { TOP_TO_BACK, TOP_TO_RIGHT, TOP_TO_FRONT, TOP_TO_LEFT, FRONT_TO_RIGHT, FRONT_TO_LEFT };

void rotate(Dice &d, FACE t[4]) {
  int tmp = d[t[3]];
  d[t[3]] = d[t[2]]; d[t[2]] = d[t[1]]; d[t[1]] = d[t[0]]; d[t[0]] = tmp;
}

vector<Dice> generate_all(Dice dice) {
  vector<Dice> res;
  for(int i = 0; i < 6; ++i) {
    for(int j = 0; j < 4; ++j) {
      res.emplace_back(dice);
      rotate(dice, tbl[FRONT_TO_RIGHT]);
    }
    if(i % 2 == 0) rotate(dice, tbl[TOP_TO_BACK]);
    else rotate(dice, tbl[TOP_TO_RIGHT]);
  }
  return res;
}

int main() {
  ios::sync_with_stdio(false);
  Dice d;
  cin >> d[TOP];
  cin >> d[FRONT];
  cin >> d[RIGHT];
  cin >> d[LEFT];
  cin >> d[BACK];
  cin >> d[BOTTOM];
  string s; cin >> s;
  for(char c : s) {
    if(c == 'S') {
      rotate(d, tbl[TOP_TO_FRONT]);
    }
    if(c == 'E') {
      rotate(d, tbl[TOP_TO_RIGHT]);
    }
    if(c == 'W') {
      rotate(d, tbl[TOP_TO_LEFT]);
    }
    if(c == 'N') {
      rotate(d, tbl[TOP_TO_BACK]);
    }
  }
  cout << d[TOP] << endl;
}