You are correct, the law that applies in this case is the law of conservation of mass. According to this law, in a chemical reaction, the total mass of the reactants is equal to the total mass of the products. This means that no atoms are created or destroyed during a chemical reaction, they are simply rearranged. Therefore, if an atom has the same amount of atoms of each element on both sides of the reaction, it fulfills the law of conservation of mass.