Pregnancy test

How soon can you take a pregnancy test after having sex?