Make sure to not confuse elements with atoms. Elements are substances used in a chemical equation that cannot be broken down. There are two elements in H2O: hydrogen and oxygen.
Atoms in the compound is the number of elements. Hydrogen would be one atom, but since it has a subscript of 2, it would mean that there are two hydrogen atoms. Oxygen is another atom, however, it does not have a subscript. Don't make that fool you because there is actually a subscript which is the understood one. That is why there are three atoms.