class Dice
  def initialize(line)
    @dice = line.split(" ").map(&:to_i)
  end
  def rot(command)
    if(command == "E") then
      @dice[0], @dice[3], @dice[5], @dice[2] = @dice[3], @dice[5], @dice[2], @dice[0]
    elsif(command == "N") then
      @dice[0], @dice[1], @dice[5], @dice[4] = @dice[1], @dice[5], @dice[4], @dice[0]
    elsif(command == "S") then
      @dice[0], @dice[1], @dice[5], @dice[4] = @dice[4], @dice[0], @dice[1], @dice[5]
    elsif(command == "W") then
      @dice[0], @dice[3], @dice[5], @dice[2] = @dice[2], @dice[0], @dice[3], @dice[5]
    end
  end
  def dispTop
    printf "%d\n", @dice[0]
  end
end

dice = Dice.new(gets.chomp)
commands = gets.chomp.split("")
commands.each {|command|
  dice.rot(command)
}
dice.dispTop