Well, knowing what the colour that each sphere or ball is in, in terms of what element it represents, simply count the total number of atoms of a particular color and do this for all of the atoms, and represent the number as a subscript for each specific atom in the compound.