class Dice
  attr_accessor :face

  def rotate_n
    @face[0],@face[1],@face[5],@face[4] = @face[1],@face[5],@face[4],@face[0]
  end
  def rotate_e
    @face[0],@face[2],@face[5],@face[3] = @face[3],@face[0],@face[2],@face[5]
  end
  def rotate_s
    @face[0],@face[1],@face[5],@face[4] = @face[4],@face[0],@face[1],@face[5]
  end
  def rotate_w
    @face[0],@face[2],@face[5],@face[3] = @face[2],@face[5],@face[3],@face[0]
  end
end

dice = Dice.new
dice.face = gets.chomp.split.map(&:to_i)
c = gets.chomp.split("")
c.each do |item|
  case item
  when "N"
    dice.rotate_n
  when "E"
    dice.rotate_e
  when "S"
    dice.rotate_s
  when "W"
    dice.rotate_w
  end
end
puts dice.face[0]