There are 25 collectable donuts in the game. Unlike with the other collectables, you have to reach the exit without dying after you grab a donut or it will not count. There is no way to check which donuts you have collected, but luckily it's very quick to see by selecting a level and looking around if there is one of those pink treats.
Levels with a donut: 2, 3, 4, 5, 8, 12, 13, 15, 16, 17, 21, 23, 24, 27, 28, 29, 30, 31, 33, 36, 37, 39, 43, 46, 47.