Every time you are asked to determine the number of pi or sigma bonds in a compound, you must draw its Lewis Structure.
Here's how the caffeine molecule looks like:
The important thing to remember is that double bonds are comprised of $$1$$ sigma bond and $$1$$ pi bond and triple bonds are comprised of $$1$$ sigma bond and $$2$$ pi bonds.
Caffeine's Lewis structure shows that no triple bonds are present; however, four double bonds are, which means that the number of pi bonds in a caffeine molecule is equal to $$4$$.
By comparison, caffeine has $$25$$ sigma bonds.