class Dice
  attr_accessor("f1","f2","f3","f4","f5","f6")

  def initialize(got)
    for i in 1..6
      eval("self.f#{i}") = got[i-1]
    end
  end
  
  def roll(dir)
    case dir
    when "N" then Dice.new([self.f2,self.f6,self.f3,self.f4,self.f1,self.f5])
    when "S" then Dice.new([self.f5,self.f1,self.f3,self.f4,self.f6,self.f2])
    when "E" then Dice.new([self.f4,self.f2,self.f1,self.f6,self.f5,self.f3])
    when "W" then Dice.new([self.f3,self.f2,self.f6,self.f1,self.f5,self.f4])
    end
  end

end

d = Dice.new(gets.split(" ").map{|i| i.to_i})
dirs = gets.split("")

for i in 0..dirs.size-1
  d = d.roll(dirs[i])
end

puts d.f0