X chromosome inactivation (XCI) is the phenomenon occurring in female mammals whereby dosage compensation of X-linked genes is obtained by transcriptional silencing of one of their two X chromosomes, randomly chosen during early embryo development. The earliest steps of random X-inactivation, involving counting of the X chromosomes and choice of the active and inactive X, are still not understood. To explain counting and choice, the longstanding hypothesis is that a molecular complex, a blocking factor (BF), exists. The BF is present in a single copy and can randomly bind to just one X per cell which is protected from inactivation, as the second X is inactivated by default. In such a picture, the missing crucial step is to explain how the molecular complex is self-assembled, why only one is formed, and how it binds only one X. We answer these questions within the framework of a schematic Statistical Physics model, investigated by Monte Carlo computer simulations. We show that a single complex is assembled as a result of a thermodynamic process relying on a phase transition occurring in the system which spontaneously breaks the symmetry between the Xs. We discuss, then, the BF interaction with X chromosomes. The thermodynamics of the mechanism that directs the two chromosomes to opposite fates could be, thus, clarified. The insights on the self-assembling and X binding properties of the BF are used to derive a quantitative scenario of biological implications describing current experimental evidences on counting and choice.