class Dice
  attr_reader :top, :bottom, :front, :back, :left, :right 
  def initialize(dice_numbers)
    @top = dice_numbers[0]
    @back = dice_numbers[1]
    @right = dice_numbers[2]
    @left = dice_numbers[3]
    @front = dice_numbers[4]
    @bottom = dice_numbers[5]
  end

  def execute_order(orders) 
      orders.each do |order|
        if order == "N"
          move_north
        elsif order == "S" 
          3.times do
            move_north
          end
        elsif order == "W"
          move_west
        elsif order == "E" 
          3.times do
            move_west
          end
        else
          puts "error!" 
        end
      end
  end
  
  private 
  def move_north
    tmp = @top
    @top = @back
    @back = @bottom
    @bottom = @front
    @front = tmp
  end

  def move_west
    tmp = @top
    @top = @right
    @right = @bottom
    @bottom = @left
    @left = tmp
  end
end

dice_numbers = gets.chomp.split.map(&:to_i)
orders = gets.chomp.split("")
dice = Dice.new(dice_numbers)
dice.execute_order(orders)
puts dice.top