Classification of square-lattice cellular automata with respect to total magnetization