class Dice
  def initialize(faces)
    @top = faces.shift
    @front = faces.shift
    @right = faces.shift
    @left = faces.shift
    @back = faces.shift
    @bottom = faces.shift
  end

  def turn_to_n
    old_top = @top
    @top = @front
    @front = @bottom
    @bottom = @back
    @back = old_top
  end

  def turn_to_e
    old_top = @top
    @top = @left
    @left = @bottom
    @bottom = @right
    @right = old_top
  end

  def turn_to_w
    old_top = @top
    @top = @right
    @right = @bottom
    @bottom = @left
    @left = old_top
  end

  def turn_to_s
    old_top = @top
    @top = @back
    @back = @bottom
    @bottom = @front
    @front = old_top
  end

  attr_reader :top
end

faces = gets.split(" ").map(&:to_i)
turns = gets.chomp.split("")

dice = Dice.new(faces)
turns.each {|t|
  case t
    when "N" then dice.turn_to_n
    when "E" then dice.turn_to_e
    when "W" then dice.turn_to_w
    when "S" then dice.turn_to_s
  end
}
puts dice.top