Look at the last one. Because one person is already the first, and B is not the last one, there are still three people left, so the last one has C3 1.
Finally, look at 2 3 4 people, because some people are already the first and last, and there are still three people left, so there are A3 3 kinds.
So there are (c 31) * (c 31) * (a33) = 54 species.