Class A had 300 books more than Class B at first. Class B gave 120 books to Class A. In the end, Class A had 5 times as many books as Class B. How many books did Class B have at first?

Let's say Class B had x books at first.

Class A had x + 300 books at first.
Class B gave 120 books to Class A.
Class A had x + 300 + 120 = x + 420 books after receiving books from Class B.
In the end, Class A had 5 times as many books as Class B, meaning Class B had x + 420 / 5 = x + 84 books.
Therefore, Class B had x = 84 books at first. Answer: \boxed{84}.