Carnot's theorem and Szil\'ard engine