//============================================================================
//dice1
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

//----------------------------------------------------------------------------
enum {pos1, pos2, pos3, pos4, pos5, pos6, posEND};
enum {posT, posS, posE, posW, posN, posB};
//----------------------------------------------------------------------------
typedef struct{
    int Dice[posEND];
    //int E;
    //int W;
    //int S;
    //int T;
    //int B;
}TCycoro;
//----------------------------------------------------------------------------
char Cmd[101];
//----------------------------------------------------------------------------
void CyRot(TCycoro *cyc, char dir)
{
    int S, cometop, betop;

    switch(dir){
        case 'N': cometop=posN, betop=posS; break;
        case 'E': cometop=posE, betop=posW; break;
        case 'W': cometop=posW, betop=posE; break;
        case 'S': cometop=posS, betop=posN; break;
        default: return;
    }
    S=cyc->Dice[cometop];
      cyc->Dice[cometop] = cyc->Dice[posT];
      cyc->Dice[posT]    = cyc->Dice[betop];
      cyc->Dice[betop]   = cyc->Dice[posB];
      cyc->Dice[posB]=S;
}
//----------------------------------------------------------------------------
void prndice(TCycoro *cyc, char dir)
{
    printf("dir:%c, N=%d, E=%d, W=%d, S=%d, T=%d, B=%d\n", dir,
            cyc->Dice[posN]+1, cyc->Dice[posE]+1, cyc->Dice[posW]+1,
            cyc->Dice[posS]+1, cyc->Dice[posT]+1, cyc->Dice[posB]+1);
}
//----------------------------------------------------------------------------
int rgtside(int t, int f)
{
    switch(t){
        case pos1:
            switch(f){
                case pos2: return pos3;
                case pos3: return pos5;
                case pos5: return pos4;
                case pos4: return pos2;
            }
            break;
        case pos2:
            switch(f){
                case pos1: return pos4;
                case pos3: return pos1;
                case pos4: return pos6;
                case pos6: return pos3;
            }
            break;
        case pos3:
            switch(f){
                case pos1: return pos2;
                case pos2: return pos6;
                case pos5: return pos1;
                case pos6: return pos5;
            }
            break;
        case pos4:
            switch(f){
                case pos1: return pos5;
                case pos2: return pos1;
                case pos5: return pos6;
                case pos6: return pos2;
            }
            break;
        case pos5:
            switch(f){
                case pos1: return pos3;
                case pos3: return pos6;
                case pos4: return pos1;
                case pos6: return pos4;
            }
            break;
        case pos6:
            switch(f){
                case pos2: return pos4;
                case pos3: return pos2;
                case pos4: return pos5;
                case pos5: return pos3;
            }
            break;
    }
    return -1;
}
//----------------------------------------------------------------------------
void rotato(int *ary)
{
    int i,n;

    for (i=0, n=*ary; i<posEND-1; i++)
        ary[i]=ary[i+1];
    ary[i]=n;
}
//----------------------------------------------------------------------------
void dice1(void)
{
    int i,cyval[posEND]; TCycoro Cyc; 

    for (i=0; i<posEND; i++)
        Cyc.Dice[i]=i;
    for (i=0; i<posEND; i++)
        scanf("%d", &cyval[i]);
    scanf("%s",Cmd);
    for (i=0; Cmd[i]; i++){
        CyRot(&Cyc, Cmd[i]);
        //printf("dir: %c, top: %d(%d)\n", Cmd[i], cyval[Cyc.T], Cyc.T+1);
        //prndice(&Cyc, Cmd[i]);
    }
    printf("%d\n", cyval[Cyc.Dice[posT]]);
}
//----------------------------------------------------------------------------
void dice3(void)
{
    int i,res, cyval1[posEND], cyval2[posEND];

    for (i=0; i<posEND; i++)
        scanf("%d", &cyval1[i]);
    for (i=0; i<posEND; i++)
        scanf("%d", &cyval2[i]);
    for (i=res=0; i<posEND; i++){
        if (!memcmp(cyval1, cyval2, posEND))
           res=1;
        rotato(cyval2);
    }
    printf("%s\n", (res)?"Yes":"No");
}
//----------------------------------------------------------------------------
int main()
{
    dice1();
    return 0;
}
//----------------------------------------------------------------------------

Measured memory_bytes: 596