On Nov. 1, 1961, the weekly variety show Perry Como’s Kraft Music Hall presented the second installment of a new feature paying tribute to the states. That week’s episode—which devoted 15 minutes to celebrating the history, geography, and culture of Missouri—debuted a jaunty new theme song for the state-saluting feature: “Fifty Nifty United States.”

Fifty nifty United States from thirteen original colonies

Fifty nifty stars in the flag that billows so beautifully in the breeze

Each individual state contributes a quality that is great

Each individual state deserves a bow

Let’s salute one now!

If you know “Fifty Nifty United States”—and, if you went to an American elementary school at some point in the past four decades, there’s a decent chance you do—the flag-billowing part is probably not the part you care about. In fact, you might not even have learned the song’s full intro. The part you care about is the part that comes next, which rivals the alphabet song as an educational tool and as an earworm: the part that rattles off all 50 states alphabetically, starting, “Alabama, Alaska, Arizona, Arkansas, California, Colorado, Connecticut,” and ending, “West Virginia, Wisconsin, Wyohhhhhh-ming!”

I learned “Fifty Nifty United States” in my fifth-grade music class in Austin, Texas, around 1997. Eighteen years later, I can barely remember what happened during the Battle of Lexington and Concord, or which constitutional amendment says what, but I can still sing the name of every state without having to think about it. The same is true for most other adults I’ve talked to who learned “Fifty Nifty United States” in childhood. And this appears to be a truly national phenomenon: I have heard from people who learned the song from sea to shining sea, in California, Connecticut, Hawaii, Illinois, Maryland, Massachusetts, Michigan, New Jersey, New York, Pennsylvania, Massachusetts, and Virginia. (No doubt it’s been taught in many of the other 37 nifty states as well.) Lin-Manuel Miranda, the MacArthur genius and writer and star of the singularly acclaimed Broadway musical Hamilton, called it “my favorite song from elementary-school chorus” before a performance in September (and then sang the state roll call flawlessly).

So how did a throwaway novelty song from a now-forgotten 1960s variety show become one of the greatest mnemonic devices in America?

Unfortunately, the song’s composer can’t tell us. Ray Charles—no, not that Ray Charles—died earlier this year at the age of 96, after a long and prolific show-business career in which he wrote, arranged, and performed dozens of compositions for stage and screen. (He’s probably best known for singing the Three’s Company theme; he also wrote music for Sha Na Na and The Muppet Show, among others.) But even when alive, Charles couldn’t shed much light on the subject. Interviewed for a South Carolina newspaper in 2008, Charles professed ignorance of how “Fifty Nifty United States” became a success after the Perry Como show: “I didn’t realize until about 10 years ago it was being used in schools,” he said.

The odds of “Fifty Nifty United States” becoming a beloved children’s classic were slim. Kraft Music Hall wasn’t exactly must-see TV—in the season that “Fifty Nifty United States” made its first appearance, it wasn’t even in the top 30 most-watched shows on TV, according to Como’s biographers. The vast majority of “special material” Charles wrote for Kraft Music was performed once, or a few times, and then forgotten. The version of “Fifty Nifty United States” that Charles wrote for Como’s show didn’t even include the roll call of state names—the ditty performed by the Ray Charles Singers was about 47 seconds long. And Como’s state-of-the-week segment never actually managed to celebrate all 50 states—Como paid tribute to only 25 states before the weekly show ended its run in 1963. (Hey, Sufjan Stevens only got around to two of them.)

As Charles’ sons Jonathan and Michael remember it, the song became immortalized because someone approached Charles about printing the song after hearing it on Kraft Music Hall. “How do you publish a tune that’s only 47 seconds long in its entirety?” asked Jonathan, 68, in an email. “He then wrote ‘the add-on,’ stacking the states in alphabetical order rather than going for the rhyme.” It does not surprise the younger Charleses that their father opted to list the states in alphabetical order. Jonathan described his father as “a saver and an archivist” who kept meticulous records and organized them carefully. “He loved putting things in alphabetical order,” Michael, 73, told me during a phone conversation. “He had a 17,000 LP collection supplemented by, like, 5,000 CDs and audio cassettes, and everything was alphabetical, either by composer or composition. He loved putting things in order like that.”

During the mid-20th century, when choral groups like the Ray Charles Singers dominated the airwaves, music publishers realized that there was an untapped market for written arrangements of popular songs. School choirs had previously been limited to classical compositions, but choir directors jumped at the chance to teach their students more accessible, modern tunes. Whoever saw fit to print and distribute “Fifty Nifty United States” probably predicted—correctly—that music educators would embrace the catchy, wholesome, patriotic song.

How, exactly, the song caught on with educators is hard to say definitely, although some clues suggest how it spread. In the summer of 1963, the song was performed at the National Education Association’s annual meeting in Michigan, possibly serving as inspiration for the thousands of educators in attendance. In 1970, the national newsletter of American Legion Auxiliary, a popular women’s patriotic group that surely included many teachers, published the lyrics as the “suggested patriotic song for October.” I heard from one American—Ray Charles’ former lawyer, actually—who learned the song at a public school in New Jersey in the late 1960s or early 1970s, which indicates that some teachers had embraced “Fifty Nifty” as a mnemonic device within a decade of the song’s invention. I also found a mention of “Fifty Nifty United States” in a program from a 1975 music conference, where it was performed by an elementary school choir from Ann Arbor.

If figuring out how “Fifty Nifty United States” became a ubiquitous educational tool is a challenge, figuring out why it became so popular is easy. I wrote to the music teacher who taught me the song, Debra Erck, who is in her 28th year of teaching at my old elementary school in Texas. Mrs. Erck said she first started teaching the song in 1988, when the Austin school district adopted a new music textbook series called Music and You, which contained the sheet music for “Fifty Nifty United States.” As you’d expect from someone who’s been teaching it for almost three decades, she had plenty of insight into the song’s appeal to children. “My students have always enjoyed learning it for its catchy tune, quick rhythms, and of course, the challenge,” she wrote to me in an email. She also pointed out that it’s more accessible to children than other patriotic tunes. “The lyrics are more current (no ‘thees’) and the range of the melody is manageable (unlike our national anthem).”

All these reasons, in hindsight, help explain why I liked learning the song so much when I was 10. And I still like the song as an adult, not only because it’s hopelessly embedded in my brain and it’d be pointless to try to fight it, but also because it might be the least jingoistic song ever written about America. “Fifty Nifty United States” isn’t, in the end, about the Founding Fathers or American exceptionalism or even how beautiful our country is. It’s just a catalog of our nation’s contents—an indisputable list of ingredients for America. As Charles said in 2008, if you know the song, “You can win a bet at the bar.’” (Even today, it’s still faster than pulling out your phone and Googling.) Charles wrote hundreds of songs and jingles over the span of his career, and, as far as his family is concerned, “Fifty Nifty United States” is not nearly the most funny, pretty, or meaningful one. But it is every bit as catchy and challenging and useful as it was the day it was written. In a country that feels more politically polarized than ever, “Fifty Nifty United States” is a rare cultural artifact: a shared experience that gets passed from one generation to the next without getting tarnished along the way.

Thanks to Marie McCarthy of the University of Michigan.