class Dice < Array
  attr_accessor("f")

  def initialize(got)
    self.f = got.split(" ").map{|i| i.to_i}
  end
  
  def roll(dir)
    case dir
    when "N" then self.f[0],self.f[1],self.f[5],self.f[4] = self.f[1],self.f[5],self.f[4],self.f[0]
    when "S" then self.f[0],self.f[1],self.f[5],self.f[4] = self.f[4],self.f[0],self.f[1],self.f[5]
    when "E" then self.f[0],self.f[2],self.f[5],self.f[3] = self.f[3],self.f[0],self.f[2],self.f[5]
    when "W" then self.f[0],self.f[2],self.f[5],self.f[3] = self.f[2],self.f[5],self.f[3],self.f[0]
    end 
    self.f
  end

end

d = Dice.new(gets)
dirs = gets.split("")

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

puts d[0]