using System;
using System.Collections.Generic;
using System.Globalization;

enum direction { north, east, west, south }
class dice{
    public int number;
    public int me;
    public dice[] east;
    public dice[] north;
    public dice[] south;
    public dice[] west;
    public int[,] direction;
};


class Program
 {
    static void Main(string[] args)
    {
        string nyuryoku;
        dice[] face = new dice[7];
        string [] temp = new string[6];
        for (int i = 1; i < 7; i++)
        {
            face[i] = new dice();
            face[i].east = new dice[4];
            face[i].west = new dice[4];
            face[i].north = new dice[4];
            face[i].south = new dice[4];
            face[i].direction = new int[4,4];
            face[i].me = i;
        }

        face[1].east[0] = face[4];
        face[1].direction[0, 1] = 1;
        face[1].north[0] = face[2];
        face[1].direction[0, 0] = 0;
        face[1].west[0] = face[3];
        face[1].direction[0, 3] = 3;
        face[1].south[0] = face[5];
        face[1].direction[0, 2] = 2;

        face[1].east[1] = face[2];
        face[1].direction[1, 1] = 1;
        face[1].north[1] = face[3];
        face[1].direction[1, 0] = 0;
        face[1].west[1] = face[5];
        face[1].direction[1, 3] = 3;
        face[1].south[1] = face[4];
        face[1].direction[1, 2] = 2;

        face[1].east[2] = face[3];
        face[1].direction[2, 1] = 1;
        face[1].north[2] = face[5];
        face[1].direction[2, 0] = 0;
        face[1].west[2] = face[4];
        face[1].direction[2, 3] = 3;
        face[1].south[2] = face[2];
        face[1].direction[2, 2] = 2;

        face[1].east[3] = face[5];
        face[1].direction[3, 1] = 1;
        face[1].north[3] = face[4];
        face[1].direction[3, 0] = 0;
        face[1].west[3] = face[2];
        face[1].direction[3, 3] = 3;
        face[1].south[3] = face[3];
        face[1].direction[3, 2] = 2;
//--------------------------------------
        face[2].east[0] = face[4];
        face[2].direction[0, 1] = 0;
        face[2].north[0] = face[6];
        face[2].direction[0, 0] = 0;
        face[2].west[0] = face[3];
        face[2].direction[0, 3] = 0;
        face[2].south[0] = face[1];
        face[2].direction[0, 2] = 0;

        face[2].east[1] = face[6];
        face[2].direction[1, 1] = 1;
        face[2].north[1] = face[3];
        face[2].direction[1, 0] = 1;
        face[2].west[1] = face[1];
        face[2].direction[1, 3] = 1;
        face[2].south[1] = face[4];
        face[2].direction[1, 2] = 1;

        face[2].east[2] = face[3];
        face[2].direction[2, 1] = 2;
        face[2].north[2] = face[1];
        face[2].direction[2, 0] = 2;
        face[2].west[2] = face[4];
        face[2].direction[2, 3] = 2;
        face[2].south[2] = face[6];
        face[2].direction[2, 2] = 2;

        face[2].east[3] = face[1];
        face[2].direction[3, 1] = 3;
        face[2].north[3] = face[4];
        face[2].direction[3, 0] = 3;
        face[2].west[3] = face[6];
        face[2].direction[3, 3] = 3;
        face[2].south[3] = face[3];
        face[2].direction[3, 2] = 3;
//--------------------------------------
        face[3].east[0] = face[2];
        face[3].direction[0, 1] = 0;
        face[3].north[0] = face[6];
        face[3].direction[0, 0] = 3;
        face[3].west[0] = face[5];
        face[3].direction[0, 3] = 0;
        face[3].south[0] = face[1];
        face[3].direction[0, 2] = 1;

        face[3].east[1] = face[6];
        face[3].direction[1, 1] = 0;
        face[3].north[1] = face[5];
        face[3].direction[1, 0] = 1;
        face[3].west[1] = face[1];
        face[3].direction[1, 3] = 2;
        face[3].south[1] = face[2];
        face[3].direction[1, 2] = 1;

        face[3].east[2] = face[5];
        face[3].direction[2, 1] = 2;
        face[3].north[2] = face[1];
        face[3].direction[2, 0] = 3;
        face[3].west[2] = face[2];
        face[3].direction[2, 3] = 2;
        face[3].south[2] = face[6];
        face[3].direction[2, 2] = 1;

        face[3].east[3] = face[1];
        face[3].direction[3, 1] = 0;
        face[3].north[3] = face[2];
        face[3].direction[3, 0] = 3;
        face[3].west[3] = face[6];
        face[3].direction[3, 3] = 2;
        face[3].south[3] = face[5];
        face[3].direction[3, 2] = 3;
//-------------------------------------
        face[4].east[0] = face[5];
        face[4].direction[0, 1] = 0;
        face[4].north[0] = face[6];
        face[4].direction[0, 0] = 1;
        face[4].west[0] = face[2];
        face[4].direction[0, 3] = 0;
        face[4].south[0] = face[1];
        face[4].direction[0, 2] = 3;

        face[4].east[1] = face[6];
        face[4].direction[1, 1] = 2;
        face[4].north[1] = face[2];
        face[4].direction[1, 0] = 1;
        face[4].west[1] = face[1];
        face[4].direction[1, 3] = 0;
        face[4].south[1] = face[5];
        face[4].direction[1, 2] = 1;

        face[4].east[2] = face[2];
        face[4].direction[2, 1] = 2;
        face[4].north[2] = face[1];
        face[4].direction[2, 0] = 1;
        face[4].west[2] = face[5];
        face[4].direction[2, 3] = 2;
        face[4].south[2] = face[6];
        face[4].direction[2, 2] = 3;

        face[4].east[3] = face[1];
        face[4].direction[3, 1] = 2;
        face[4].north[3] = face[5];
        face[4].direction[3, 0] = 3;
        face[4].west[3] = face[6];
        face[4].direction[3, 3] = 0;
        face[4].south[3] = face[2];
        face[4].direction[3, 2] = 3;
//------------------------------------
        face[5].east[0] = face[3];
        face[5].direction[0, 1] = 0;
        face[5].north[0] = face[6];
        face[5].direction[0, 0] = 2;
        face[5].west[0] = face[4];
        face[5].direction[0, 3] = 0;
        face[5].south[0] = face[1];
        face[5].direction[0, 2] = 2;

        face[5].east[1] = face[6];
        face[5].direction[1, 1] = 3;
        face[5].north[1] = face[4];
        face[5].direction[1, 0] = 1;
        face[5].west[1] = face[1];
        face[5].direction[1, 3] = 3;
        face[5].south[1] = face[3];
        face[5].direction[1, 2] = 1;

        face[5].east[2] = face[4];
        face[5].direction[2, 1] = 2;
        face[5].north[2] = face[1];
        face[5].direction[2, 0] = 0;
        face[5].west[2] = face[3];
        face[5].direction[2, 3] = 2;
        face[5].south[2] = face[6];
        face[5].direction[2, 2] = 0;

        face[5].east[3] = face[1];
        face[5].direction[3, 1] = 1;
        face[5].north[3] = face[3];
        face[5].direction[3, 0] = 3;
        face[5].west[3] = face[6];
        face[5].direction[3, 3] = 1;
        face[5].south[3] = face[4];
        face[5].direction[3, 2] = 3;
//-----------------------------------
        face[6].east[0] = face[4];
        face[6].direction[0, 1] = 3;
        face[6].north[0] = face[5];
        face[6].direction[0, 0] = 2;
        face[6].west[0] = face[3];
        face[6].direction[0, 3] = 1;
        face[6].south[0] = face[2];
        face[6].direction[0, 2] = 0;

        face[6].east[1] = face[5];
        face[6].direction[1, 1] = 3;
        face[6].north[1] = face[3];
        face[6].direction[1, 0] = 2;
        face[6].west[1] = face[2];
        face[6].direction[1, 3] = 1;
        face[6].south[1] = face[4];
        face[6].direction[1, 2] = 0;

        face[6].east[2] = face[3];
        face[6].direction[2, 1] = 3;
        face[6].north[2] = face[2];
        face[6].direction[2, 0] = 2;
        face[6].west[2] = face[4];
        face[6].direction[2, 3] = 1;
        face[6].south[2] = face[5];
        face[6].direction[2, 2] = 0;

        face[6].east[3] = face[2];
        face[6].direction[3, 1] = 3;
        face[6].north[3] = face[4];
        face[6].direction[3, 0] = 2;
        face[6].west[3] = face[5];
        face[6].direction[3, 3] = 1;
        face[6].south[3] = face[3];
        face[6].direction[3, 2] = 0;

        dice inital = face[1];


        nyuryoku = Console.ReadLine();
        temp = nyuryoku.Split(' ');
        for (int i = 1; i < 7; i++)
            face[i].number = int.Parse(temp[i-1]);
     
        nyuryoku = Console.ReadLine();
        int position = 1;
        int muki = 0;
        for (int i = 0; i < nyuryoku.Length; i++)
        {
           // Console.WriteLine(" me = {0} muki = {1}", position, muki);
            switch (nyuryoku[i])
            {
                case 'S':
                    inital = face[position].south[muki];
                    muki = face[position].direction[muki, 2];
                    position = inital.me;
                    break;
                case 'N':
                    inital = face[position].north[muki];
                    muki = face[position].direction[muki, 0];
                    position = inital.me;
                    break;
                case 'E':
                    inital = face[position].east[muki];
                    muki = face[position].direction[muki, 1];
                    position = inital.me;
                    break;
                case 'W':
                    inital = face[position].west[muki];
                    muki = face[position].direction[muki, 3];
                    position = inital.me;
                    break;
            }
           // Console.WriteLine(" me = {0} muki = {1}", position, muki);

        }
 
        Console.WriteLine("{0}", inital.number);

    }
 }



Measured memory_bytes: 17980