Walk through the front doors of Montgomery Blair High School in Silver Spring and you'll be greeted by two brightly lighted soda machines hawking Coke, Diet Coke, Sprite and other sticky-sweet carbonated beverages.

Just down the hall stand three more. Two others are around the corner, just past the snack vending machines. Throughout the school, there are 22 soda machines in all, including one catty-corner from the principal's office. All conveniently take dollar bills.

"When people ask, I tell them we have as many machines as we have electrical plugs," Principal Phillip Gainous said. "If we had more plugs, we would have more soda machines."

Gainous's fondness for soda machines is simple: They bring in a lot of cash for him to spend on his school as he sees fit -- more than $40,000 in some years. That's enough to help defray the cost of scholarships, club activities, bus transportation, school materials, enrichment programs, computer labs and even clothes for some of the school's neediest students.

As state and local funding for education has grown tighter, many high schools in the Washington area have been following Blair's example and installing more vending machines on campus. But nutrition specialists are beginning to rebel at the practice, saying it undermines efforts to teach children the importance of eating a balanced diet. They say they worry that some schools may be turning a blind eye toward federal, state and local regulations restricting the sale of snacks and sodas that are not part of the regular school lunch program.

"It's a very controversial, Catch-22 situation," said Kathleen Lazor, director of food and nutrition services for Montgomery County schools.

Most school principals say they try to turn off their machines during the day or prohibit sales during certain hours. But the lure of vending machine revenue often is too tempting to resist completely, they say, and the increasing use of school buildings by outside groups creates a natural opportunity to make money for the school.

Steven Dickoff, principal at Watkins Mill High School in Gaithersburg, said the profits from his 11 machines have paid for more than $15,000 worth of computer equipment that was beyond the budget of his school.

At Thomas Jefferson High School for Science and Technology in Fairfax County, Principal Jeffrey Jones said the 12 soda machines are so popular that various clubs and organizations stock the machines themselves for rights to the profits. The booster club oversees one machine, the student government another. Even the faculty adopted the one in the teachers lounge.

"It just gives the various groups a pool of money to work with," Jones said.

Sen. Patrick J. Leahy (D-Vt.) found out just how desperate school systems are for vending machine revenue in 1994 when he sought to have the Department of Agriculture advise school districts that they had the right to prohibit soda sales during the school day.

Representatives from the beverage industry joined with education organizations such as the National Association of Secondary School Principals to oppose the legislation, calling it coercive and warning that it could lead to a decline in fund-rais\ing. The legislation, however, ultimately passed despite their objections.

"These vending profits go for good causes," Leahy said. "But when it comes to vending machine junk food, it would be better to put pupils ahead of vending profits."

Gainous said he was troubled by the conflicting message he might send about the importance of nutrition when he first considered bringing more soda machines into the school. But Blair, like many high schools, allows students to leave campus for lunch, and Gainous said he noticed many students would bring sodas back to school after buying them elsewhere.

"Like it or not, the kids were drinking sodas anyway. Instead of letting them spend that money out there {off campus}, we said, Let's get them to spend a little of that money here and help the school,' " Gainous said.

Initially it was difficult to bring more than a few machines on campus because many of the hallway electrical outlets didn't work. But that problem soon was resolved when the supplier at the time, a Pepsi bottler, sent an electrician to make repairs.

The action was not unusual given the perennial competition between Pepsi and Coke, with each trying to outdo the other by offering schools better profits or inducements such as free stadium scoreboards.

"You're probably seeing more activity now," said Kate Whiting, spokeswoman for Mid-Atlantic Coca-Cola Bottling Co. "But we've always been in the schools."

No matter who provides the product, the vending machines are popular among students. Jessica Ray, a Blair freshman, said she buys a soda every day, in part because the cafeteria lines are too long. Besides, she said with a sly smile, "I can't have soda at home."

Demitria Nyamweya, a 10th-grader, said she probably buys about two cans of soda a day from the vending machines. She said she might buy juice from one of the other vending machines, but "it's more expensive."

A 12-ounce can of juice from a machine costs 75 cents; a similar-size can of Coke is 65 cents, while a 20-ounce bottle with a screw-on cap is 85 cents.

And what about buying milk from the cafeteria? "Who wants milk?" Demitria said, laughing. "We have milk for breakfast."

Demitria's mother, Mary Nyamweya, said she wishes the school didn't make it so easy for students to buy sugary beverages. "If they continue to drink so much, I'm concerned with the effect on their bodies," Nyamweya said.

But Catherine Ray, Jessica's mother, said she doesn't mind the school machines because she would prefer that her daughter not go off campus in search of a drink. "As for nutritional value, I know there's none. But she doesn't get any {soda} at home," Ray said.

In recent years, nutritionists have grown increasingly concerned that teenagers are substituting soft drinks for milk at meals or drinking them instead of eating balanced meals.

Lazor, the school nutritionist in Montgomery, said sodas are appropriate as snacks if consumed in moderation. But she said there's a reason foods of minimal nutritional value are found "at the top of the food pyramid."

"It's supposed to make up the smallest amount of food you consume each day," Lazor said. "It's not something that's essential to the stability of the pyramid or good nutrition."

Gainous said Blair teachers continue to stress the importance of good eating habits. But it is hard to ignore what he's been able to accomplish with the "soda money," as it's called in the school.

Over the years, soda money has paid for computers and all the wiring needed to create a computer network. Gainous has spent some of the profits on enrichment programs and transportation costs for needy students who have won scholarships to special programs off campus. The money has paid for field trips and teacher training. Occasionally, Gainous dips into the fund to buy clothes for a student who can't afford the nice pants or shoes a job might require.

Last summer, Gainous used soda money to cover the $1,500 cost of running buses for a summer-long enrichment program available to elementary schools around Blair. "The schools all thanked me, but I told them: These are my kids, my families. If we help them now, it'll help me later,' " when they get to high school, Gainous said.

Gainous said he leaves many of the spending decisions up to individual departments, as long as they live by one rule.

"Every department gets a cut of the money to use for their discretion as long as it goes back to the kids," Gainous said. CAPTION: Students at Montgomery Blair High use one of the 22 soda machines in the Silver Spring school, which in some years has reaped more than $40,000 in profits from soft drink sales.