It matters not if it was your primary residence at foreclosure. It matters if you are physically living in the unit at the time the owner wanted to take possession.