Can you take Melatonin in 3rd trimester?

I have such a hard time sleeping, is melatonin safe and how many Mg’s?