A full rigged ship originally had nine square sails, three on each mast. Later the topsail and t'gallant were split into two and royals, skysails and even moonrakers were added so you could end up with eight sails per mast without stunsails. The yard is the timber that holds up the square sails, the yardarm is only the bit protruding beyond where the sail is bent onto the yard, often painted white.