class Dice
  def initialize(t,s,e,w,n,b)
    @val = [t,s,e,w,n,b]
  end
  def roll(d)
    case d
    when "N" then
      @val = [@val[1],@val[5],@val[2],@val[3],@val[0],@val[4]]
    when "E" then
      @val = [@val[3],@val[1],@val[0],@val[5],@val[4],@val[2]]
    when "W" then
      @val = [@val[2],@val[1],@val[5],@val[0],@val[4],@val[3]]
    when "S" then
      @val = [@val[4],@val[0],@val[2],@val[3],@val[5],@val[1]]
    end
  end
  def getTop
    return @val[0]
  end
end

t,s,e,w,n,b = gets.chomp.split(" ").map{|x| x.to_i}
commands = gets.chomp.split("")
d = Dice.new(t,s,e,w,n,b)
for c in commands do
  d.roll(c)
end
result = d.getTop
printf("%d\n",result)
