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

namespace LogicSummoner
{
    class Program
    {
        enum Directoin
        {
            N,
            E,
            W,
            S,
            U,
            D,
        }

        class Dice
        {
            private int[] nums = new int[6];
            private List<Directoin> dirs;
            public Dice(IEnumerable<int> nums)
            {
                this.nums = nums.ToArray();
                dirs = new List<Directoin>()
                {
                    Directoin.U,
                    Directoin.S,
                    Directoin.E,
                    Directoin.W,
                    Directoin.N,
                    Directoin.D,
                };
            }
            public void Rotate(Directoin move)
            {
                switch (move)
                {
                    case Directoin.N:
                        for (int i = 0; i < dirs.Count; i++)
                        {
                            switch (dirs[i])
                            {
                                case Directoin.N:
                                    dirs[i] = Directoin.D;
                                    break;
                                case Directoin.E:
                                    break;
                                case Directoin.W:
                                    break;
                                case Directoin.S:
                                    dirs[i] = Directoin.U;
                                    break;
                                case Directoin.U:
                                    dirs[i] = Directoin.N;
                                    break;
                                case Directoin.D:
                                    dirs[i] = Directoin.S;
                                    break;
                                default:
                                    break;
                            }
                        }
                        break;
                    case Directoin.E:
                        for (int i = 0; i < dirs.Count; i++)
                        {
                            switch (dirs[i])
                            {
                                case Directoin.N:
                                    break;
                                case Directoin.E:
                                    dirs[i] = Directoin.D;
                                    break;
                                case Directoin.W:
                                    dirs[i] = Directoin.U;
                                    break;
                                case Directoin.S:
                                    break;
                                case Directoin.U:
                                    dirs[i] = Directoin.E;
                                    break;
                                case Directoin.D:
                                    dirs[i] = Directoin.W;
                                    break;
                                default:
                                    break;
                            }
                        }
                        break;
                    case Directoin.W:
                        for (int i = 0; i < dirs.Count; i++)
                        {
                            switch (dirs[i])
                            {
                                case Directoin.N:
                                    break;
                                case Directoin.E:
                                    dirs[i] = Directoin.U;
                                    break;
                                case Directoin.W:
                                    dirs[i] = Directoin.D;
                                    break;
                                case Directoin.S:
                                    break;
                                case Directoin.U:
                                    dirs[i] = Directoin.W;
                                    break;
                                case Directoin.D:
                                    dirs[i] = Directoin.E;
                                    break;
                                default:
                                    break;
                            }
                        }
                        break;
                    case Directoin.S:
                        for (int i = 0; i < dirs.Count; i++)
                        {
                            switch (dirs[i])
                            {
                                case Directoin.N:
                                    dirs[i] = Directoin.U;
                                    break;
                                case Directoin.E:
                                    break;
                                case Directoin.W:
                                    break;
                                case Directoin.S:
                                    dirs[i] = Directoin.D;
                                    break;
                                case Directoin.U:
                                    dirs[i] = Directoin.S;
                                    break;
                                case Directoin.D:
                                    dirs[i] = Directoin.N;
                                    break;
                                default:
                                    break;
                            }
                        }
                        break;
                    default:
                        break;
                }
            }
            public int Getnum(Directoin dir)
            {
                return nums[dirs.IndexOf(dir)];
            }
        }

        static void Main(string[] args)
        {
            var nums = GetNumbersInt();
            var dice = new Dice(nums);
            var dirs = Console.ReadLine().Trim().Select(x => (Directoin)Enum.Parse(typeof(Directoin), x.ToString())).ToList();
            foreach (var d in dirs)
            {
                dice.Rotate(d);
            }
            System.Console.WriteLine(dice.Getnum(Directoin.U));
        }

        //static StreamReader Console = new StreamReader("input.txt");

        static int GetNumber()
        {
            return int.Parse(Console.ReadLine().Trim());
        }

        static double GetDounble()
        {
            return double.Parse(Console.ReadLine().Trim());
        }

        static int[] GetNumbersInt(int n = 0)
        {
            return Console.ReadLine().Trim().Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries).Select(x => int.Parse(x)).ToArray();
        }

        static long[] GetNumbersLong(int n = 0)
        {
            return Console.ReadLine().Trim().Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries).Select(x => long.Parse(x)).ToArray();
        }

        static double[] GetNumbersDouble(int n = 0)
        {
            return Console.ReadLine().Trim().Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries).Select(x => double.Parse(x)).ToArray();
        }

        static string[] GetStrings(int n = 0)
        {
            return Console.ReadLine().Trim().Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries).ToArray();
        }
    }
}

Measured memory_bytes: 10136