You can apply for a permanent residence permit in Denmark after completing eight years of legal residence there.