Nature of the metal-insulator transition in few-unit-cell-thick LaNiO3 films