How long after sex?

How long after sex can you take a pregnancy test?