Count from the date you got your first continuous residence permit. Time on a temporary permit counts half. Up to 365 days abroad in total count, but no more than 90 in the last year.