The morning after pill

How does the morning after pill work. I had unprotected sex with my boyfriend and am a little worried.