BANGKOK (Reuters) - Wearing crisp red-and-white uniforms, a group of 60-year-olds pile into a bus, smiling broadly as they make their way to a school in Ayutthaya, a province in Thailand.

Slideshow ( 25 images )

For this group, and others across the country, going back to school offers a way to fight loneliness at a time when changing demographics mean more elderly people are living alone.

“I’ve been looking forward to every Wednesday, when I go to school, dress up as a school student and meet friends. We get to talk and laugh together,” said Somjit Teeraroj, a 77-year-old widow who is a student at the school for the elderly in Ayutthaya’s Chiang Rak Noi subdistrict.

After the death of her husband of 40 years, with her children visiting occasionally, Somjit said it was the school that helped her recover from her loss. (Click reut.rs/2rrLx4x to see a picture package on Thailand's elderly going back to school)

Somjit’s story is emblematic of a larger problem in Thailand - a rapidly ageing population.

Thailand, together with China, is ageing faster than its regional neighbours. By 2040, it is expected to have the highest share of elderly people of any developing country in East Asia, according to the World Bank.

Thailand has 7.5 million people aged 65 and over, a figure projected to swell to 17 million by 2040 - more than a quarter of the expected population.

Traditionally, ageing Thais lived at home with their families and were cared for by their children. But with many leaving the countryside to work in the cities, parents and grandparents are increasingly being left alone.

Schools like the one in Ayutthaya, 80 km (49.71 miles) north of Bangkok, that offer weekly classes over three months are the government’s way of offering older people relief from the stresses of living alone.

“It’s stressful just living day by day,” 63-year-old Choochart Supkerd told Reuters.

“I will probably go back to feeling lonely sometimes but I’m also proud of this, of gaining some knowledge in class,” said Choochart, after posing for a picture with the class of 2018 in his gold-trimmed red graduation gown and a flower crown.