Pregnancy test

How soon can you take a pregnancy test after unprotected sex and it be accurate??