#include <iostream>
#include <stdio.h>
using namespace std;
int main(void){
    int a,b,c,d,e,f,n=0;
    int T,N,S,E,W,B;
    char A;
    cin >> a >> b >>c >> d >> e >>f;
    while(n<=100){
        T=a;S=b;E=c;W=d;N=e;B=f;
  //   printf("%d\n",T);
        cin >> A;
        if(A=='N'){
          // p=a;a=e;e=f;f=b;b=p;
            f=N;e=T;a=S;b=B;A=0;
        }else if(A=='S'){
         // p=f;f=e;e=a;a=b;b=p;
            a=N;e=B;f=S;b=T;A=0;
        }else if(A=='E'){
          //  p=d;d=a;a=c;c=f;f=p;
            c=T;a=W;d=B;f=E;A=0;
        }else if(A=='W'){
          //  p=c;c=a;a=d;d=f;f=p;
            d=T;a=E;c=B;f=W;A=0;
        }
        n=n+1;
//printf("%d",a);
  //      printf(" %d\n",T);
  
    }
    printf("%d\n",T);
}

