class Dice
  def initialize(b,s,e,w,n,vals)
    @bottom=b
    @s,@e,@w,@n=s,e,w,n
    @vals=vals
  end

  def move(n)
    case n
    when "S"
      @n=@bottom
      @bottom=@s
      @s=7-@n
    when "N"
      @s=@bottom
      @bottom=@n
      @n=7-@s
    when "E"
      @w=@bottom
      @bottom=@e
      @e=7-@w
    when "W"
      @e=@bottom
      @bottom=@w
      @w=7-@e
    end
  end

  def top
    puts @vals[6-@bottom]
  end
end

vals=gets.split
d=Dice.new(6,2,3,4,5,vals)
gets.chomp.chars{|c| d.move(c)}
d.top