Planck 2015 results: XXIV. Cosmology from Sunyaev-Zeldovich cluster counts