using System;
using System.Collections.Generic;
using System.Linq;

class Program {
    private static int Main() {
        var input = Console.ReadLine();
        var values = input.Split( ' ' );

        var numbers = values.Select<string, int>( _ => int.Parse( _ ) );
        var dice = new Dice( numbers );

        input = Console.ReadLine();
        foreach( var d in input ) {
            dice.Roll( d );
        }

        Console.WriteLine( dice.Get() );

        return 0;
    }


    /// <summary>
    /// サイコロクラス
    /// </summary>
    class Dice {

        /// <summary>
        /// 向き情報
        /// </summary>
        enum Direction {
            South,
            North,
            East,
            West,
        }

        /// <summary>
        /// 各ラベルに描かれた数値
        /// </summary>
        int[] numbers;

        /// <summary>
        /// 現在のX軸のテーブル
        /// </summary>
        int[] tableX;

        /// <summary>
        /// 現在のY軸のテーブル
        /// </summary>
        int[] tableY;

        /// <summary>
        /// 現在のX軸テーブルに対するインデックス
        /// </summary>
        int tableXIndex;

        /// <summary>
        /// 現在のY軸テーブルに対するインデックス
        /// </summary>
        int tableYIndex;
        
        /// <summary>
        /// コンストラクタ
        /// </summary>
        /// <param name="numbers">各ラベルに描かれた数値</param>
        public Dice( IEnumerable<int> numbers ) {
            this.numbers = numbers.ToArray();

            // テーブルの初期化
            this.tableX = new int[] { 0, 1, 5, 4 };
            this.tableY = new int[] { 0, 2, 5, 3 };
            this.tableXIndex = 0;
            this.tableYIndex = 0;
        }

        /// <summary>
        /// ダイスを転がす
        /// </summary>
        /// <param name="directionChar">向きデータの文字</param>
        public void Roll( char directionChar ) {
            Roll( GetDirection( directionChar ) );
        }

        /// <summary>
        /// ダイスを転がす
        /// </summary>
        /// <param name="direction">転がす向き</param>
        void Roll( Direction direction ) {
            switch( direction ) {
                case Direction.South: 
                    MoveX( -1 );
                    break;
                case Direction.North:
                    MoveX( 1 );
                    break;
                case Direction.East:
                    MoveY( -1 );
                    break;
                case Direction.West:
                    MoveY( 1 );
                    break;
                default:
                    throw new Exception( "Unknown direnction: " + direction );
            }
        }

        private void MoveX( int moveIndex ) {
            this.tableXIndex = ( this.tableXIndex + 4 + moveIndex ) % 4;
            this.tableY[ this.tableYIndex ] = this.tableX[ this.tableXIndex ];
            this.tableY[ ( this.tableYIndex + 2 ) % 4 ] = this.tableX[ ( this.tableXIndex + 2 ) % 4 ];
        }

        private void MoveY( int moveIndex ) {
            this.tableYIndex = ( this.tableYIndex + 4 + moveIndex ) % 4;
            this.tableX[ this.tableXIndex ] = this.tableY[ this.tableYIndex ];
            this.tableX[ ( this.tableXIndex + 2 ) % 4 ] = this.tableY[ ( this.tableYIndex + 2 ) % 4 ];
        }

        /// <summary>
        /// 現在の出目を取得
        /// </summary>
        /// <returns>現在の出目</returns>
        public int Get() {
            return this.numbers[ this.tableX[ this.tableXIndex ] ];
        }

        /// <summary>
        /// 向きデータの取得
        /// </summary>
        /// <param name="directionChar">向きデータの文字</param>
        /// <returns>向きデータ</returns>
        private static Direction GetDirection( char directionChar ) {
            switch( directionChar ) {
                case 'S':
                    return Direction.South;
                case 'N':
                    return Direction.North;
                case 'E':
                    return Direction.East;
                case 'W':
                    return Direction.West;
                default:
                    throw new Exception( "Unknown direction: " + directionChar );
            }
        }
    }
}

Measured memory_bytes: 20272