can you??

can you get pregnant if you have sex just before your period and you have your period does that mean you are all safe? so no pregnancy? or will the sperm still be inside you and then after you get pregnant when you come off your period?? i’m confused help me!!