Sanhedrin, Chapter Ten, Mishnah Five
Mishnah five (and mishnah six) contain midrashim, exegeses, on the verses in Deuteronomy that discuss the city seduced into idol worship. The structure of these mishnayoth is to quote a verse and then bring a law that is derived from that verse.
1) You shall surely smite the inhabitants of that city with the edge of the sword (Deut. 13:16): a company of donkey-drivers or camel-drivers passing from place to place saves the city.
2) Doom it and all that is in it (ibid.): From here they said that the property of the righteous, which is within [the city] is destroyed, but that which is outside of the city is saved, while that of the wicked, whether in or outside of the city, is destroyed.
Section one: The verse states that you must smite the inhabitants of the city. If, however, there are people living in the city who are not permanent inhabitants, such as donkey or camel drivers, they are not counted as part of the city in order to add up to the majority needed for the city to be declared a seduced city. Occasionally they may save the city from being doomed.
Section two: From the words and all that is in it the Rabbis learn that even the property of the righteous is to be destroyed. However, from the words doom it, the Rabbis understand that the Torah is limiting that which is destroyed. The property which belongs to the righteous that is outside of the city is therefore not destroyed. However, the property of the wicked is destroyed whether or not it is in the city itself.