Sex before period and pregnancy

Is there a chance to become pregnant hours before your period having unprotected sex ? I had u protected sex hours before my period almost 5-6 days  later I took the generic plan B and a week later I was spotting for two days , is there a chance of being pregnant ? I took a test but it came out negative