Section 24. Whoever steals in a building which is on fire, or steals property which has been removed in consequence of an alarm caused by fire, shall be punished by imprisonment in the state prison for not more than five years or by a fine of not more than five hundred dollars and imprisonment in jail for not more than two years.