using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace _20170409_AOJ
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] iArr = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            string dirs = Console.ReadLine();

            Dice dice = new Dice(iArr);
            foreach(var v in dirs.ToCharArray())
            {
                dice.Move(v);
            }

            Console.WriteLine(dice.Top);

            Console.ReadLine();
        }
    }

    class Dice
    {
        public enum Dir
        {
            N,
            S,
            W,
            E,
            L,
            R
        }


        int[] iArr = new int[6];
        int[,] tenkai;
        public Dice(int[] arr)
        {
            int len = Math.Min(iArr.Length, arr.Length);
            for (int i = 0; i < len; i++)
            {
                iArr[i] = arr[i];
            }

            tenkai = CreateTenkai();
        }

        public int Top
        {
            get { return iArr[tenkai[1, 1]]; }
        }

        public void Move(char c)
        {
            switch (c)
            {
                case 'N': Move(Dir.N); break;
                case 'S': Move(Dir.S); break;
                case 'W': Move(Dir.W); break;
                case 'E': Move(Dir.E); break;
                case 'L': Move(Dir.L); break;
                case 'R': Move(Dir.R); break;
            }
        }

        public void Move(Dir dir)
        {
            switch(dir)
            {
                case Dir.N:
                    {
                        int tmp = tenkai[1, 1];
                        tenkai[1, 1] = tenkai[2, 1];
                        tenkai[2, 1] = tenkai[1, 3];
                        tenkai[1, 3] = tenkai[0, 1];
                        tenkai[0, 1] = tmp;
                    }
                    break;
                case Dir.S:
                    {
                        int tmp = tenkai[1, 1];
                        tenkai[1, 1] = tenkai[0, 1];
                        tenkai[0, 1] = tenkai[1, 3];
                        tenkai[1, 3] = tenkai[2, 1];
                        tenkai[2, 1] = tmp;
                    }
                    break;
                case Dir.W:
                    {
                        int tmp = tenkai[1, 1];
                        tenkai[1, 1] = tenkai[1, 2];
                        tenkai[1, 2] = tenkai[1, 3];
                        tenkai[1, 3] = tenkai[1, 0];
                        tenkai[1, 0] = tmp;
                    }
                    break;
                case Dir.E:
                    {
                        int tmp = tenkai[1, 1];
                        tenkai[1, 1] = tenkai[1, 0];
                        tenkai[1, 0] = tenkai[1, 3];
                        tenkai[1, 3] = tenkai[1, 2];
                        tenkai[1, 2] = tmp;
                    }
                    break;
            }
        }

        private int[,] CreateTenkai()
        {
            int[,] arr = new int[,]{
                { -1,  4, -1, -1 },
                {  3,  0,  2,  5 },
                { -1,  1, -1, -1 },
            };

            return arr;
        }
    }
}

Measured memory_bytes: 9568