using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            new DiceCalculator();
        }

        public static List<string> Splitter(string input)
        {
            var result = new List<string>();
            int spaces = input.Where(a => a == ' ').Count();
            int pos = 0;
            for (int i = 0; i <= spaces; i++)
            {
                input = input.Remove(0, pos);
                pos = input.IndexOf(" ");
                if (pos == 0 || pos == -1) { pos = input.Length; }
                string text = "";
                for (int j = 0; j < pos; j++)
                {
                    text += input[j];
                }
                result.Add(text);
                pos++;
            }
            return result;
        }

        public static List<int> IntParser(List<string> input)
        {
            var result = new List<int>();
            foreach(var i in input)
            {
                int num;
                Int32.TryParse(i, out num);
                result.Add(num);
            }
            return result;
        }
    }

    class DiceCalculator
    {
        public DiceCalculator()
        {
            var dice = new Dice
            {
                Side = Program.IntParser(Program.Splitter(Console.ReadLine())).ToArray()
            };
            var commands = CommandSplitter(Console.ReadLine());
            foreach (var s in commands)
            {
                dice.Roll(s);
            }
            Console.WriteLine(dice.GetTopValue().ToString());
            Console.ReadKey();
        }

        public static List<string> CommandSplitter(string input)
        {
            var result = new List<string>();
            foreach(var c in input)
            {
                result.Add(c.ToString());
            }
            return result;
        }
    }

    class Dice
    {
        public int[] Side;

        public Dice()
        {
            Side = new int[6];
        }

        public int GetTopValue()
        {
            return Side[0];
        }

        public void Roll(string direction)
        {
            var newside = new int[6];
            switch (direction)
            {
                case "N":
                    newside[0] = Side[1];
                    newside[1] = Side[5];
                    newside[2] = Side[2];
                    newside[3] = Side[3];
                    newside[4] = Side[0];
                    newside[5] = Side[4];
                    break;
                case "E":
                    newside[0] = Side[3];
                    newside[1] = Side[1];
                    newside[2] = Side[0];
                    newside[3] = Side[5];
                    newside[4] = Side[4];
                    newside[5] = Side[2];
                    break;
                case "S":
                    newside[0] = Side[4];
                    newside[1] = Side[0];
                    newside[2] = Side[2];
                    newside[3] = Side[3];
                    newside[4] = Side[5];
                    newside[5] = Side[1];
                    break;
                case "W":
                    newside[0] = Side[2];
                    newside[1] = Side[1];
                    newside[2] = Side[5];
                    newside[3] = Side[0];
                    newside[4] = Side[4];
                    newside[5] = Side[3];
                    break;
            }
            Side = newside;
        }
    }
}



Measured memory_bytes: 19012