In a closed system the reacting species interconvert but do not leave the system. Therefore the amounts of different species in the system would be bound by a conservation rule.

>A simple example:
$$\ce{A -> B}$$

Here the conservation rule would be: $\ce{A + B = constant}$, which says that at any point of time during the reaction the sum of the amount of both the species would be constant.

> A more complex example
$$\ce{2A -> B}$$

Here, the conservation rule would be: $\ce{A + 2B = constant}$.

Let's take a more complex system:
> $$\begin{align}
\ce{A &-> B} \\
\ce{2B &-> C} \\
\ce{C &-> D + E} \\ 
\ce{2A + C &-> F}
\end{align}$$

From empirical analysis I can deduce that the conservation rule would be: $$\ce{A + B + 2C + D + E + 4F = constant}$$

However, I am not able to deduce a mathematical equation that gives these co-efficients. I assume that the stoichiometry matrix may give a clue but I am not sure. The stoichiometry matrix for the above system is:

$$\mathbf{S}=\begin{bmatrix}
-1 & 0 & 0 & -2 \\
1 & -2 & 0 & 0 \\
0 & 1 & -1 & -1 \\
0 & 0 & 1 & 0 \\
0 & 0 & 1 & 0 \\
0 & 0 & 0 & 1
\end{bmatrix}$$

The problem seems quite elementary but I am not able to solve it. Am I missing something obvious?