Measurement of the open-charm contribution to the diffractive proton structure function