Study of the primary cosmic ray composition with the MACRO experiment at Gran Sasso