#include <stdio.h>
#include <vector>
#include <array>
#include <string>
#include <iostream>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <unordered_map>

using std::string;
using std::vector;


// [ ][1][ ][ ]
// [4][2][3][5] 
// [ ][6][ ][ ] 
//
//    ^ S
// < W   > E
//    v N

// class Side{
// public:
//     int number;
//     vector<int> dest;
//     Side(const vector<int>& news){
//         dest = news;
//     }
//     int nextTop(char direction){
//         switch (direction) {
//             case 'N':
//                 return dest[0];
//                 break;
//             case 'E':
//                 return dest[1];
//                 break;
//             case 'W':
//                 return dest[2];
//                 break;
//             case 'S':
//                 return dest[3];
//                 break;
//             default:
//                 return -1;
//         }
//     }
// };


class Dice {
private:
    // [ ][5][ ]
    // [4][1][3] 
    // [ ][2][ ] 
    int board[3][3];
    int bottom;
public:
    Dice(vector<int> legends) {
        for (int i = 0; i < 3; i++) {
            for (int j = 0; j < 3; j++) {
                board[i][j] = -1;
            }
        }
        this->board[0][1] = legends[5-1];
        this->board[1][0] = legends[4-1];
        this->board[1][1] = legends[1-1];
        this->board[1][2] = legends[3-1];
        this->board[2][1] = legends[2-1];
        this->bottom = legends[6-1]; 
        // printBoard();
    }
    void move(char direction) {
        switch (direction) {
            case 'N': {
                int tempBottom = board[0][1];
                board[0][1]    = board[1][1];
                board[1][1]    = board[2][1];
                board[2][1]    = this->bottom;
                this->bottom   = tempBottom;
                printBoard();
                break;
            }

            case 'E': {
                int tempBottom = board[1][2];
                board[1][2]    = board[1][1];
                board[1][1]    = board[1][0];
                board[1][0]    = this->bottom;
                this->bottom   = tempBottom;
                printBoard();
                break;
            }
            case 'W': {
                int tempBottom = board[1][0];
                board[1][0]    = board[1][1];
                board[1][1]    = board[1][2];
                board[1][2]    = this->bottom;
                this->bottom   = tempBottom;
                printBoard();
                break;
            }
            case 'S': {
                int tempBottom = board[2][1];
                board[2][1]    = board[1][1];
                board[1][1]    = board[0][1];
                board[0][1]    = this->bottom;
                this->bottom   = tempBottom;
                printBoard();          
                break;
            }
        }
    }
    void printBoard() {
        // printf("------------\n");
        // for(int i = 0; i < 3; i++) {
        //     for(int j = 0; j < 3; j++){
        //         printf("[% d] ", this->board[i][j]);
        //     }
        //     printf("\n");
        // }
    }    
    int top() {
        return this->board[1][1];
    }
};
int main(){
    int n1, n2, n3, n4, n5, n6;
    scanf("%d %d %d %d %d %d", &n1, &n2, &n3, &n4, &n5, &n6);
    Dice dice({ n1, n2, n3, n4, n5, n6 });

    char buffer[100 + 1];
    scanf("%s", buffer);
    string directions(buffer);

    for(auto each: directions) {
        dice.move(each);
    }
    printf("%d\n", dice.top());
    
    return 0;
}


Measured memory_bytes: 3296