That's one tricky question :p
Let's do it step by step.
"8 ghouls each had 8 hands": So there's 8 ghouls. Each ghoul have 8 hands, so there's a total of 8*8 = 64 hands.
"Each hand had 8 warts": There's 64 hands, and each have 8 warts.
So there's a total of 64*8 = 512 warts.
"Each wart had 8 hairs": There's 512 warts, and each have 8 hairs.
So there's a total of 512*8 = 4096 hairs.
So there were 4096 hairs!
Hope this Helps! :)