How long after can you take the morning after pill?

This is gonna sound like a dumb question but how long after you have sex can you still take the morning after pill? My boyfriend and I had unprotected sex 2 days ago for about 20 seconds and he didn't cum but I'm still really nervous. Is it possible that I could get pregnant?