Plan B

If I have unprotected sex right after I take plan B is the pill still as affective as taking it after?