Sex after miscarriage

Is it safe to have sex after bleeding stopped after a miscarriage? Or should I wait till my first period