The Hilbert function of two ideals