Squaring Legs

Tom just bought some scroboscopi, so he is reading a book of facts about them. He finds that on each day of its life a scroboscopus squares its number of legs. For example, if a scroboscopus had two legs on the first day of its life, it would have 4 legs on the second day of its life, 16 legs on the third day of its life, and so on. Some have 2 legs to start with, some 3 legs, and some 5 legs. Before they have a chance to increase their number of legs, the total leg count of the scroboscopi that Tom bought came out to 58 legs. The next day the total leg count came out as 164. The day after that the total number of legs increased to 1976. How many scroboscopi did Tom buy?

(Source: Mathematics Teaching in the Middle School, Oct 1995)