For prison inmates in Brazil, good behavior isn't the only thing that gets them closer to freedom—pedaling a bike to help power a nearby town can, too.

Through an innovative—and eco-friendly—program, prisoners can cut down their sentences by putting in some time on stationary bikes hooked up to car batteries, according to the Associated Press. As the inmates pedal, the car batteries are charged.

The charged-up batteries are then used to illuminate 10 street lamps in the nearby town of Santa Rita do Sapucai. The town's mayor told the AP he came up with the idea after learning about gyms in the United States that use electricity generated by exercise bikes.

Volunteers in the medium-security prison earn one day off their sentence for every three eight-hour shifts they spend on the bikes, which were salvaged from the local police department's lost and found. One inmate has already reduced his sentence by 20 days, and his weight by about 9 pounds, thanks to the two-month-old program.

The power provided by those incarcerated in Santa Rita do Sapucai has revived a riverside promenade once abandoned after dark, according to locals. Now with the street lamps powered, the area attracts dog walkers, joggers, and kids on bikes.

The program is one of several across Brazil designed to cut the number of repeat offenders. Inmates in some other Brazilian prisons can reduce their sentences by reading books or taking classes. Supporters say the programs could eventually help curb overcrowding in Brazilian prisons, which currently hold upwards of 500,000 inmates.

"It's a win-win situation," the prison's director, Gilson Rafael Silva, told the AP. "People who normally are on the margins of society are contributing to the community and not only do they get out sooner in return, they also get their self-esteem back."