Dinosaurs are still with us. Every sparrow you see carries on the legacy of creatures as fantastic as Tyrannosaurus and Triceratops. But this delightful truth also brings up one of the longest-standing mysteries in paleontology . . . why did the avian dinosaurs survive the asteroid when all their relatives died out? By doing dental work on million-year-old fossils, paleontologists think that they’ve finally found the plot twist: The ancestors ate seeds to ride out the apocalypse.

The new study, published last week in Current Biology, gives an inkling to what happened at the very end of the dinosaurs' heyday, Royal Ontario Museum paleontologist and study author David Evans says. Previous work had hinted that the number of large, herbivorous dinosaur species were in decline up until about 66 million years ago, but no one had looked at smaller, fuzzier dinosaurs to see if the same pattern held. Evans and his colleagues were looking to unravel one of the major mysteries of what paleontologists call the K/Pg extinction—the mass extinction so famous it inspired movies like Armageddon and The Good Dinosaur. But the team also wanted to figure out how ancestors of modern birds survived while more archaic, toothed birds and their Velociraptor-like cousins perished.

To crack the mystery, the paleontologists needed a lot of teeth. Most of what we know about the ancestors of modern birds and their relatives comes from dental records; teeth are the main way to get a head count of small, feathered dinosaurs and predict what they were eating, 20 million years prior to the Cretaceous catastrophe, Evans says. He and his colleagues examined a whopping set of 3,104 fossilized teeth—extracted from 82- to 66-million-year-old North American rock—to determine how many of these feathery dinosaurs were present, and if their diets had shifted over time.

They found that among prehistoric birds and toothy dinosaurs, there was no sign of decline leading up to the day the asteroid struck; birds and their sharp-clawed kin were going strong right until the end. “We found that small, feathered theropod communities were ecologically diverse and stable for the last 18 million years of the Age of Dinosaurs,” Evans says. This runs counter to the belief that these dinosaurs started fading back just before the extinction.

But this in turn created a new mystery. If toothy birds and dinosaurs weren’t gradually fading, why did they die out? And why did the toothless ancestors of modern birds survive? Evans suspects that beaks are the answer. “Many toothed birds, as well as small, feathered raptor dinosaurs, most likely ate animals,” Evans says, “but many early modern birds, which are characterized by their toothless beaks, likely had the ability to eat seeds.” This gave the ancient birds an unexpected advantage.

In the good times preceding the asteroid, there was plenty of food to sustain both carnivores and vegans. After the extraterrestrial shock, however, forest fires, debris that blocked out the sun, and other environmental catastrophes may have stripped the planet of most plant and animal life. Feathered dinosaurs and birds that still had teeth starved—but the seedeaters stuck around.

There’s even modern-day evidence that supports this theory, Evans adds. “It turns out that seed-eating birds are very typically the first vertebrates back into disturbed habitats ravaged by forest fires,” he says. It wasn’t size, ferocity, or even feathers that saved the avian dinosaurs. Quite simply, it was because the early bird got the seeds.