Q:

How many admirals are in Starfleet?

Let's say in the TNG era.  
They seem to be pretty rare given that they have to be promoted mostly from the ranks of the most accomplished captains.    I would guess maybe twenty are encountered or mentioned over the course of TNG.
Are there a dozen or a hundred?

A:

There is no canon or extended universe source that states unequivocally  the total number of admirals in Starfleet.  However, if we assume that each branch of Starfleet is administered by at least one admiral (of some rank), then we can easily arrive at a lower bound:
Here are the branches of Starfleet, according to Memory Alpha:

Academy
Administration
Administrative Operations
Advanced Technologies
Applied Sciences Division
Command
Communications
Control
Daystrom Institute
Dental (yes, really; Starfleet Dental is shown on Admiral Layton's display in DS9 : "Paradise Lost")
Diplomatic Corps
Engineering (including Engineering Corps)
Exploration (including Deep Space Exploration)
Fleet Supply and Inventory
Information
Office of the Inspector General
Intelligence
Internal Affairs
Office of the Judge Advocate General
Material Supply Authority
Medical
Mission Operations
Office of Special Planning
Operations
Operational Support
Orbital Operations
Operational Safety and Health Command
Planetary Geosciences
Research and Development (General)
Research and Development (Propulsion)
Research and Development (Spaceframes)
Science
Section 31 (separate from Intelligence)
Security
Shipyards Operations
Stellar Cartography
Stellar Imaging
Systems Management
Tactical
Tactical Analysis (separate from Tactical, apparently)
Terrestrial Defense
Training Command

This makes for at least 42 admirals of various ranks.  (We can assume that the Commander-in-Chief of Starfleet is the admiral who is the Branch Head of Starfleet Command.)
In any case, counting admirals by counting Starfleet branches would not include those admirals who are away on diplomatic or ambassadorial assignments, nor would it include admirals who are not Branch Heads but who serve on branch committees. Starfleet Tactical likely has a large committee of admirals who discuss short-term and long-term fleet strategy.  There may also be several admirals serving as instructors at Starfleet Academy.
So the best we can say is at least 42 admirals, but probably many more.

A:

In the TNG episode "Phantasms" Picard sadly tells Riker (emphasis added):

I've been invited to the annual Starfleet Admirals' banquet. I've managed to avoid it for the past six years, but now it would seem my luck has run out. I can't think of anything more tedious. Fifty admirals shaking hands, making dull conversation, uninteresting food, boring speeches.

So we know there are at least 50 in Starfleet.

