RIO DE JANEIRO (AP) " The path to the Olympic podium for British athletes begins with the selection of six numbers.
Every time a Briton fills in a lottery slip and hands over two pounds ($2.60), the country moves closer to another Olympic medal.
And medals of every hue are now in the possession of athletes sporting the union jack flag.
It wasn't always like this. The Olympics used to be just like the World Cup for Britain's soccer teams: Stories of near-misses, plucky losers and embarrassment.
But funding from the National Lottery has fueled the transformation of British sports from the nadir of the 1996 Olympics. Britain left Atlanta with a single gold among 15 medals, stranded in 36th place in the standings. Team GB, as it is known, was the second-best nation in Rio de Janeiro with 67 medals across 19 sports, squeezing China out of second place.
By surpassing the 2012 haul by two medals with fewer athletes, Britain became the first Olympic hosts to improve their showing at the next games. Rio has been Britain's best games since 1908, with only the United States ahead.
The 27th and final gold was won on Saturday night on the track by Mo Farah.
"We have achieved a lot as a nation," said Mo Farah, who defended his titles in the 5,000- and 10,000-meter races. "The legacy has changed since 2012. We are winning a lot more and, to finish second in the medal count, I'm proud of our country."
UK Sport, the government agency that allocates cash from the state and the lottery to Olympic and Paralympic sport, said Britain is now a "sporting superpower."
Jack Laugher and Chris Mears claimed Britain's first-ever diving gold and Max Whitlock became the country's first Olympic gymnastics champion. All 14 British cyclists who competed won medals. The swimmers enjoyed their best games in more than 30 years.
"This is not happening by chance," Simon Timson, performance director at UK Sport, said. "This is success by design. It's the result of 18 years of consistent, coherent and targeted National Lottery investment.
"The partnership we have with the British Olympic Association and the money we've invested into the Team GB's final preparations is one of those elements of success by design."
The lottery was launched in 1994, two years before the debacle of Atlanta left British athletes scurrying back into Britain with no fanfare.
The discussion now is where to hold the victory parade. Manchester in northern England is displacing London for the bus tour this year, a chance to display the gold, silver and bronze medals that have briefly reunited a nation divided by the referendum vote to leave the European Union in June.
It was a British prime minister whose reign was defined at the time by divisions over Europe who created the lottery that spurred the sporting success. John Major's "greatest achievement was to change the face of sport" in the country, IAAF President Sebastian Coe, the double-Olympic middle-distance champion, has said. In the last year, 20 percent of lottery funds were injected into sports.
Investing in talent searches, facilities and coaching allows Britain to unearth those whose sporting ability never found a competitive outlet. Those who make it into Team GB then benefit from the expertise of the leading coaches and world-class facilities. Before the lottery, many representing Britain had to scrape a living to fund their sporting dreams.
As funding has increased so has Britain's medal haul:
" In the buildup to the 2000 Sydney Games, 58.9 million pounds ($77 million) was invested in 13 sports. Britain finished 10th with 28 medals, including 11 golds.
" Before the 2004 Athens Games, 71 million pounds was invested in 16 sports, producing another 10th place finish but with 30 medals including nine golds.
" Hiking the cash to 235 million pounds across 27 sports, once UK Sport became responsible for investment in development, led to a surge to fourth place in Beijing in 2008. Among 47 medals, 19 were gold.
" Much was focused on a successful London Games in 2012. The athletes justified the 264 million pounds spread across 27 sports by securing third spot ahead of Russia with 65 medals, including 29 golds.
"Most nations invest in two- or four-year projects," Timson said. "We invest in athletes and coaches and support staff in eight-year pathways."
The cash isn't dispersed frivolously. Sports that don't meet pre-games medal targets can have their funding cut.
There is criticism of a system that churns out cash to produce results at the elite level, rather than targeting more handouts at grassroots facilities to boost grassroots participation.
"A relatively small number of sports feature regularly on prime time TV, so for many the Olympic Games is the moment that catapults them onto the screens of the nation," Sport England chief executive Jennie Price said. "We need to capitalize on that."
Britain used to rule through the world through its empire. The former imperial power is showing itself to be a force again internationally " at the Olympics.
Rob Harris at www.twitter.com/RobHarris and www.facebook.com/RobHarrisReports
This story has been automatically published from the Associated Press wire which uses US spellings