EU issues 3.1 million residence permits in 2017