Sam ranked ninth from the top and thirty-eight from the bottom in a class. How many students are there in the class?