We'll start by calling the number of pigeons we started with x, because it's the unknown.
After she clapped 1/3 flew away so she was left with
(1 - 1/3) x = (2/3) x
Two flew back, so now there are
(2/3) x + 2
She clapped again and half left, half stayed, so now
(1/2) ( (2/3) x + 2 )
One came back and there were five,
(1/2) ( (2/3) x + 2 ) + 1 = 5
Solving is unraveling.
(1/2) ( (2/3) x + 2 ) = 4
(2/3) x + 2 = 8
(2/3) x = 6
x = (3/2) 6 = 9
Answer: 9 pigeons
Check: Reviewing the story, 9 -> 6 -> 8 -> 4 -> 5 good