The pill

Recently had a miscarriage and I don't want to go through that again and am not ready for a baby, I know my boyfriend and I plan to have sex again and was wondering how soon I would be able to take the pill after m.c.?