Measurement of the diffractive structure function in deep inelastic scattering at HERA