class Dice
  def initialize num_dict
    @num=num_dict

    @top=1
    @bottom=6
    @right=3
    @left=4
    @forward=5
    @backward=2

  end
  
  def getTop
    @num[@top]
  end

  def moveE
    temp=@top
    @top=@left
    @left=@bottom
    @bottom=@right
    @right=temp
  end

  def moveW
    temp=@top
    @top=@right
    @right=@bottom
    @bottom=@left
    @left=temp
  end

  def moveN
    temp=@top
    @top=@backward
    @backward=@bottom
    @bottom=@forward
    @forward=temp
  end
  
  def moveS
    temp=@top
    @top=@forward
    @forward=@bottom
    @bottom=@backward
    @backward=temp
  end

  def rotate(char)
    case char
      when "E"
        moveE
      when "W"
        moveW
      when "N"
        moveN
      when "S"
        moveS
    end
  end
end

a,b,c,d,e,f=STDIN.gets.split(" ")
dice=Dice.new({1 => a.to_i , 2 => b.to_i , 3 => c.to_i , 4 => d.to_i , 5 => e.to_i , 6 => f.to_i})

order=STDIN.gets

order.chars do |char|
  dice.rotate(char)
end
puts dice.getTop 