Pregnant and confused

So I had sex during my fertile period. My husband came inside of me and I got my period. But today I went to the hospital because I had some pains. I just got off my period today and they said I'm pregnant and I'm just shocked.