Whatever composition results in the most microstates is what the system will spontaneously select. So we use the permutational equation to count the number of microstates available in a system:
Wc = N!/(N1!*N2!...*Ni!)
It’s really not that bad. Wc is the number of microstates, and the subscript C indicates that we are only examining the configurational possibilities (ignoring the energy contribution). The variable N is for the number of particles or items or whatever in your system, and the Ni in the denominator is how many of each kind of thing there are in the system, where i is a generic that ranges from 1 to however many different things you are analyzing. The ! is the factorial function which tells you how many different ways there are two arrange a set of things.
So for our super simple system that begins with four A’s and four B’s, N=8 because there are 8 total things and the denominator has two terms, Na=4 because there are four A’s and Nb=4 because there are four B’s. When we plug this information into the formula above, it becomes:
Wc = N!/(Na!*Nb!) = 8!/(4!*4!) = 40,320/576 = 70
In written language then, there are 70 ways to permute 4 of one kind of thing and four of another kind of thing. Ok but what about for the second state after the reaction has taken place once, and there are three A’s, three B’s, and one C? Well now N=7 and the denominator has three terms, Na, Nb, and Nc, for the number of molecules of type A, B, and C respectively. Putting this into the permutational equation we get:
Wc = N!/(Na!*Nb!*Nc!) = 7!/(3!*3!*1!) = 5,040/36 = 140
Do you see what happened mathematically? The numerator got much smaller when the particle number changed from 8 to 7 but the denominator decreased faster as a result of a new thing being put into the system. Dividing by a small number is the same as multiplying by a big number and so the overall number of possible microstates increases as a result of the reaction. When the microstates increase the configurational entropy increases as well and so the second law will promote the spontaneous formation of a new molecule of C.