No, only you can help yourself by doing the homework assigned. If someone else did it for you, then how are you supposed to learn anything?

You didn't even specify a language. However the basic way I would go about this is use the language's built-in method for getting directory names, stuff that into a while loop that terminates when it gets a null value or whatever the return value is when it doesn't find any more directories.

It's up to you if you want to feed all the results into an array, and then loop over the array of the directory tree, searching for whatever it is you're looking for. It's more work, but it would make the program much more readable later, and flexible, but I can see an argument being made for just doing it all at the same time via a set of nested while loops.

The counter bit is easy, just incrementing a counter variable every time you find a match. That's a pretty straight forward if loop.

You're on your own to write the actual code, that's just the basic outline of how I would make such a program.