Even a male cell can count the number of X chromosomes. (Lee et al. 1996; Cell 86: 83-84)
When X inactivation is getting started the two chromosomes "kiss" - a process that lasts for a couple of hours (first shown by Jeannie Lee in 1996). The physical contact between two X chromosomes is over a small fraction of the chromosome but it's essential for triggering inactivation. (Xu et al. 2006: Science 311: 1149-52)
If it doesn't happen then the X chromosome assumes it's alone which would mean that Xist never gets switched on and inactivation never happens (a key stage in chromosome counting).
Chromosome counting is a process in which cells determine somehow
their intrinsic chromosome number(s). The best-studied cellular
mechanism that involves chromosome counting is 'chromosome-kissing'
and X-chromosome inactivation (XCI) mechanism. It is necessary for the
well-known dosage compensation between the genders in mammals to
balance the number of active X-chromosomes (Xa) with regard to diploid
set of autosomes. At the onset of XCI, two X-chromosomes are coming in
close proximity and pair physically by a specific segment denominated
X-pairing region (Xpr) that involves the SLC16A2 gene.
Take a look at Xist and Tsix. Some more papers worth taking a look at:
Xist regulation and function eXplored
Mechanism of regulation of ‘chromosome kissing’ induced by Fob1 and its physiological significance