Most people would rather not think about their waste once the toilet flushes (or even before), but fortunately some do. We can thank those people for figuring out what to do with that waste, along with effluent from manufacturing and stormwater draining off city streets. We can also thank them for finding the value that would otherwise be left behind. There’s gold in them thar sewage. There’s millions in it.

Researchers from Arizona State University recently estimated exactly how much gold, silver and other metals end up in sewage sludge. Sludge is the "goo left behind when treating sewage," reports Warren Cornwall for Science. The team ran sludge samples from around the U.S. through a mass spectrometer, an instrument that can analyze exactly what kind of elements are in a sample by ionizing them in plasma. They found that a million person city can produce about $13 million worth of metal annually, including $2.6 million in silver and gold. That shakes out to about $280 per ton of sludge of the 13 most valuable elements—silver, copper, gold, platinum and more, they reported in the journal Environmental Science & Technology.

How does that gold and other precious metal get into the sewage? It might be waste from mining, electroplating, electronics and jewelry manufacturing. Already, metals in sewage pose a problem for disposal, so removing it could be doubly useful.

The study didn’t take into account how expensive it might be to get the treasure out of the trash, but study author and environmental engineer Paul Westerhoff told Science that figuring out a way might be worth it. Cornwall writes:

One city in Japan has already tried extracting gold from its sludge. In Suwa in Nagano Prefecture, a treatment plant near a large number of precision equipment manufacturers reportedly collected nearly 2 kilograms of gold in every metric ton of ash left from burning sludge, making it more gold-rich than the ore in many mines.

U.S. sewage plants haven’t tried to get gold out yet, but the idea that sewage is just waste has changed. About 60 percent of sludge is used to fertilize fields and forests, Caldwell reports. The rest is incinerated or put in landfills. At some point, when technology has advanced and our need is great, mining those landfills might even pay off.