  We present constraints on the number of Galactic magnetars, which we have
established by searching for sources with periodic variability in 506 archival
Chandra observations and 441 archival XMM-Newton observations of the Galactic
plane (|b|<5 degree). Our search revealed four sources with periodic
variability on time scales of 200-5000 s, all of which are probably accreting
white dwarfs. We identify 7 of 12 known Galactic magnetars, but find no new
examples with periods between 5 and 20 s. We convert this non-detection into
limits on the total number of Galactic magnetars by computing the fraction of
the young Galactic stellar population that was included in our survey. We find
that easily-detectable magnetars, modeled after persistent anomalous X-ray
pulsars, could have been identified in 5% of the Galactic spiral arms by mass.
If we assume there are 3 previously-known examples within our random survey,
then there are 59 (+92,-32) in the Galaxy. Transient magnetars in quiescence
could have been identified throughout 0.4% of the spiral arms, and the lack of
new examples implies that <540 exist in the Galaxy (90% confidence). Similar
constraints are found by considering the detectability of transient magnetars
in outburst by current and past X-ray missions. For assumed lifetimes of 1e4
yr, we find that the birth rate of magnetars could range between 0.003 and 0.06
per year. Therefore, the birth rate of magnetars is at least 10% of that for
normal radio pulsars. The magnetar birth rate could exceed that of radio
pulsars, unless the lifetimes of transient magnetars are >1e5 yr. Obtaining
better constraints will require wide-field X-ray or radio searches for
transient X-ray pulsars similar to XTE J1810--197, AX J1845.0--0250, CXOU
J164710.2--455216, and 1E 1547.0-5408.
