class Dice
   def initialize()
      #top bottom N S E W
      @dice_number = [1,6,5,2,3,4]
   end

   def swap(number)
      number.map { |n|
      @dice_number[0],@dice_number[n]= @dice_number[n],@dice_numbe[0] }
   end
   
   def throw(command)
      swap_number =[]
      
      case command
      when "N"
         swap_number =[2,1,4]
         swap(swap_number)
      when "E"
         swap_number =[3,1,5]
         swap(swap_number)
      when "N"
         swap_number =[4,1,2]
         swap(swap_number)
      when "N"
         swap_number =[5,1,3]
         swap(swap_number)
   end
   def top
      @dice_number[0]
   end
   
end

number = gets.split.map(&:to_i)
command = gets.chomp.split("")
 
dice = Dice.new
 
command.map do |c|
    dice.throw(c)
end
 
puts number[dice.top-1]