class Dice
  attr_reader :top, :bottom, :front, :back, :left, :right #dice.top????????§???????????????????????????

  def initialize(dice_numbers) #dice????????????????¨??????????
    @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) #???????????????????????§????????????????????????????????????
    if orders.size == 1 #??????????????¨????????´????????¨?????????????????????
      if orders == "N"
        move_north
      elsif orders == "S" #3???north?????¢????????¨1???south?????¢??????????????¨????????¶????????????
        3.times do
          move_north
        end
      elsif orders == "W"
        move_west
      elsif orders == "E" #3???east?????¢????????¨1???west?????¢??????????????¨????????¶????????????
        3.times do
          move_west
        end
      else
        puts "error!" #?????¬????????????????????????
      end
    else
      orders.each do |order| #??????????????????????????¨????????????????????¢?????????
        if order == "N"
          move_north
        elsif order == "S" #3???north?????¢????????¨1???south?????¢??????????????¨????????¶????????????
          3.times do
            move_north
          end
        elsif order == "W"
          move_west
        elsif order == "E" #3???east?????¢????????¨1???west?????¢??????????????¨????????¶????????????
          3.times do
            move_west
          end
        else
          puts "error!" #?????¬????????????????????????
        end
      end
    end
  end
  # p "[#{top}, #{back}, #{right}, #{left}, #{front}, #{bottom}]"
  private #class?????§????????????????????????
  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