Measurement of the Q2 and energy dependence of diffractive interactions at HERA