The answer is 29 .
I haven't any idea of solving mathematically but i can explain it logically!!'
Since the Tan packs the pencils either in Bundles of 5 or bundles of 9 .
When She packs in bundles of 5 she is left with 4 extra pencils, hence she will have five bundles of pack 5 as 5*5 = 25 and she will have extra 4 pencils
hence 25 + 4 = 29
When She packs in bundles of 9 she will need 7 more ,
hence 9*3 = 27 and 2 are remaining and hence she needs 7 more pencils to pack a new bundle
hence 29 is the answer!!!
Hope this helps you!!!