Using sets to calculate number of used classes