how long after having sex do you take a pregnancy test?

how long after having sex should you wait to take a preganacy test?