In one molecule of carbon dioxide, there are a total of 3 atoms, 2 carbon atoms and one oxygen atom. Since the formula is CO2, it means there is 1 C (carbon) and 2 O (oxygen).
Since it is a covalent compound (2 non metals), it has a name in front of the elements (usually), mono for one, di for 2, tri for 3 etc. With this, we can figure out how many atoms there are in carbon dioxide.