class Dice
 
  def move(command)
    if(command == "E") 
      @dice[0], @dice[3], @dice[5], @dice[2] = @dice[3], @dice[5], @dice[2], @dice[0]
    elsif(command == "N") 
      @dice[0], @dice[1], @dice[5], @dice[4] = @dice[1], @dice[5], @dice[4], @dice[0]
    elsif(command == "S") 
      @dice[0], @dice[1], @dice[5], @dice[4] = @dice[4], @dice[0], @dice[1], @dice[5]
    elsif(command == "W") 
      @dice[0], @dice[3], @dice[5], @dice[2] = @dice[2], @dice[0], @dice[3], @dice[5]
    end
  end

  def top
    printf "%d\n", @dice[0]
  end
end
 
@dice = Dice.new(gets.chomp)
commands = gets.chomp.split("")
commands.each {|command|
  dice.move(command)
}
dice.top
