S. Korea's total population rises for first time in three years due to inflow of foreign residents