Count legal residence only. The law needs at least four years in the six before your last twelve months, so five years in all.