#include<iostream>
#include<cstdio>
using namespace std;
int main() {
	int siz[6], damy;
	char mozi[2];
	for (int abc = 0; abc < 6; abc++) {
		cin >> siz[abc];
	}
	fgets(mozi,2,stdin);
	while(true){
		fgets(mozi,2,stdin);
		if (mozi[0] == '\n') {
			cout << siz[0] << endl;
			break;
		}
		switch (mozi[0]) {
		case 'S':
			damy = siz[0];
			siz[0] = siz[4];
			siz[4] = siz[5];
			siz[5] = siz[1];
			siz[1] = damy;
			break;
		case 'E':
			damy = siz[0];
			siz[0] = siz[3];
			siz[3] = siz[5];
			siz[5] = siz[2];
			siz[2] = damy;
			break;
		case 'N':
			damy = siz[0];
			siz[0] = siz[1];
			siz[1] = siz[5];
			siz[5] = siz[4];
			siz[4] = damy;
			break;
		case 'W':
			damy = siz[0];
			siz[0] = siz[2];
			siz[2] = siz[5];
			siz[5] = siz[3];
			siz[3] = damy;
			break;
		}
	}
	return 0;
}
 #include<iostream>
 #include<stdio.h>
 #include<string>
 #include<math.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 #include<stack>
 #include<queue>
 #include<functional>
 #include<utility>
 
 using namespace std;
 
 int main()
 {
   int up,down,front,back,left,right;
   cin>>up>>front>>right>>left>>back>>down;
   string com;
   cin>>com;
   for(int i=0;i<com.length();i++)
   {
     if(com[i]=='S')
     {
       int temp=down;
       down=front;
       front=up;
       up=back;
       back=temp;               
     }
     else if(com[i]=='W')
     {
       int temp=left;
       left=up;
       up=right;
       right=down;
       down=temp;     
     }
     else if(com[i]=='N')
     {
       int temp=front;
       front=down;
       down=back;
       back=up;
       up=temp;     
     }
     else
     {
       int temp=up;
       up=left;
       left=down;
       down=right;
       right=temp;   
     }        
   }
   cout<<up<<endl;
   //while(1);
   return 0;
 }