Your question makes no sense. There is no fixed number of years in Canada required for getting permanent residency, and there is no fixed number of years in Canada which guarantees permanent residency. It is sometimes possible to get permanent residency before ever entering Canada, for example by family sponsorship, or the federal skilled worker class. It is also possible to spend many years in Canada without ever qualifying for permanent residency, for example on a student visa.
You may be thinking of Canadian citizenship. You need to spend three years in Canada as a permanent resident to qualify for Canadian citizenship (this will soon change to four years). Only years spent in Canada after you get PR count for citizenship.
I have answered your question for citizenship. As I already said, you need PR first, before you can apply for citizenship. Your question still makes no sense for PR. There is no set number of years that you "need" for PR because number of years in Canada is not a determinative factor in PR applications. It's like asking how many chocolate cakes do I need for PR.