As the place of A is changed by 18 -9 = 9
Similarly the place of B is changed by = 5 + 9 = 14 from the right.
Total no. of students = 18 + 5 - 1 = 24
(As A is at the 18th place from left after interchanging with the place of B and also 5th from the right).
Hence, the place of B from the right after interchanging = 22 - 9 + I = 14th.