Women ovulate approximately 14 days before their next period. In fact, it's the ovulation that triggers the next period. The variable in a woman's cycle is the amount of time between her period and the NEXT ovulation, not between ovulation and menstruation.
Therefore, a woman can't ovulate 'a few days before' her next period, that phase of the cycle just can't be that short, biologically.
As for a woman can ovulating during
her cycle, this can happen if woman has a VERY VERY VERY short cycle (15 to 20 days) and a long period.
There is no way you had already gone into the ovulation phase on the first day of your period.
In fact, of all the days in the entire cycle, the first day of the period is probably the safest. (Not that I'm advocating ever using the rhythm method!)
Anyway, all that was to say that there's absolutely no way you can get pregnant from what you did. So you don't need to stress (but I would advise going to buy some condoms!