class Dice
   attr_accessor :dice,:top

   def initialize(nums)
      @dice = nums
      @top = nums[0]
   end

   def throw(direction)
      case direction
      when "S"
         @dice = [@dice[4],@dice[0],@dice[2],@dice[3],@dice[5],@dice[1]]
      when "N"
         @dice = [@dice[1],@dice[5],@dice[2],@dice[3],@dice[0],@dice[4]]
      when "W"
         @dice = [@dice[2],@dice[1],@dice[5],@dice[0],@dice[4],@dice[3]]
      when "E"
         @dice = [@dice[3],@dice[1],@dice[0],@dice[5],@dice[4],@dice[2]]
      end
      @top = @dice[0]
   end
end

nums = gets.chomp.split.map(&:to_i)
directions = gets.chomp

dice = Dice.new(nums)
directions.each_char do |char|
   dice.throw(char)
end
puts dice.top