[Permanent] residence permit

My situation is complicated. I have been living in Finland since 2002 but always with a student visa until four years ago I got a residence permit for work. Now my permit  is expiring, and I could be entitled to the permanent residence permit. But in the meanwhile I lost my job, and now I am unemployed. My current income is benefits  from Kela. It seems that I have no grounds to apply for the permanent residence permit, as well as for other residence permits, loosing all my efforts of many years. An advice is much appreciated. Thank you!

New topic