The ratio of teachers to students is 5:8. Divide the number 1400 into 13 (5+8) groups and we get 107 rem 9. 13*107=1391 and if we take 5/13*1391 we get 535 teachers and 8/13*1391=856 students. 535/856=5/8. If the remaining group of 9 were all students, they would have no teacher. An additional 4 would mean we could have 5 teachers and 8 students, so we take 5 out of the 9 to be teachers, making 540 teachers in all, but one group of 5 teachers would have only 4 students between them instead of 8. If we had 3 teachers instead of 5 then there would be 538 teachers (862 students) with a group of 3 teachers covering 6 students, which is closer to the required ratio: 1:2 instead of 5:8. (538/862=0.62413 compared with 5/8=0.62500).
The same result is obtained by working out 5/13*1400=538 to the nearest whole number.