(CNN) -- Looking back on it, Wendy Fox thinks it was the M&M's that did her in.
They sat in a glass bowl on her living room table, taunting her every time she walked by, seemingly calling out for her to scoop up a few and eat them. Eat them she did, as well as anything else chocolaty that crossed her path, such as a brownie at her favorite restaurant or a mocha drink at Starbucks.
Fox's chocolate cravings (and three pregnancies) helped her gain 40 pounds in her 30s.
"It wasn't pretty," says Fox, 41, a real estate agent in Weston, Massachusetts.
Unhappy with her growing figure -- she'd gone from a size 4 to a size 10 -- Fox watched as her mother lost 30 pounds. Her mother, who also craves sweets, had attended a program with nutritionist Susan Roberts at Tufts University to curb cravings and suggested Fox do the same.
"At my first meeting with Sue, I told her, 'You've met your challenge,' " Fox remembers with a laugh.
Roberts, author of "The Instinct Diet," explained to Fox that there's a biological reason most of us crave ice cream and not broccoli, but we can unlearn our instincts. It worked. After 14 months, Fox now craves salads instead of M&M's, has lost 36 pounds and is back down to a size 4.
The caveman's instinct
"For most of human history, people didn't have enough to eat, so fat was something you really needed to seek out," says Marcia Pelchat, a food psychologist at the Monell Chemical Senses Center in Philadelphia.
To avoid dying in a famine, the brain is wired to pick up on signs that calorie-rich foods are nearby, which helps explain why that piece of cake on the plate in front of you is so irresistible, or why seeing a sign for a doughnut shop draws you in even when you know you need to watch your diet.
"It's analogous to a drug addict who's gone through rehab, but when he walks by that abandoned crack house he suddenly thinks about going in again," Pelchat says.
Pelchat adds, however, that while we're born with certain cravings, there's also evidence we start to crave whatever we eat in large quantities. She found this when she put study subjects on a vanilla-flavored drink low in saturated fat. After consuming it every day for two weeks, about a third of the subjects reported craving the drink, even though she says, "It was chalky and not very yummy."
Research in Japan also shows that cravings are influenced by our environment. A study at Tohoku University found that many Japanese women crave sushi. "These findings suggested that the craving for some kind of food is influenced by the tradition of food products and cultures," the authors concluded.
'Chocolate makes me nauseous!'
It was tough at first, but Fox, once a chocoholic, now hardly ever craves chocolate.
"I couldn't believe it, but last night we were at a friend's house for dinner and when they served dessert, I thought, 'I can't wait to go home and have a bowl of high-fiber cereal.' "
Her biggest craving now is for salad.
"I make one every night for dinner -- leafy greens and chopped up cucumbers. I don't use dressing -- just a little bit of olive oil and salt and pepper, because I crave a natural taste," she says. "This is such a huge difference for me."
Every so often, Fox says she gets a "ping" for chocolate. But then when she eats it, it makes her feel sick.
"I can just taste the butter in the first bite. It makes me nauseous, which is so weird, because I'm the M&M girl!" she says. "I think a lot of it is psychological. I worked so hard to get where I am that I don't want to go back there. A brownie's not going to take me down!"
Judith Beck, a psychologist and president of the Beck Institute for Cognitive Behavior Therapy in Pennsylvania, says she has noticed the same phenomenon when her patients have given up foods they used to crave.
"They didn't like the sensation of greasy foods in their mouths, and sometimes foods high in sugar started to taste too sweet," she says.
Learning to crave salad
Here are three steps toward switching your cravings from fatty foods to healthy foods.
1. Clean out your cupboards
Fox removed all signs of chocolate from her home. She replaced the M&M's in the glass bowl with pretty marbles, and if she buys chocolate for a special occasion, she gets rid of it immediately.
"I just had a party for my kids and we made ice cream sundaes. As soon as it was over, I gave the leftover hot fudge to my neighbors," she says.
2. Carry around healthy foods
Fox carries apples in her purse and keeps a box of high-fiber cereal in her car so she can dig in whenever a chocolate craving hits.
3. Bury craved foods in the middle of a meal
For the first two weeks, Roberts tells dieters to avoid eating unhealthy craved foods altogether, in the hopes of helping them unlearn the craving. After two weeks, she tells them they can have 100 calories of that food in the middle of the meal.
"I call it the sandwich technique," she says. "If you eat chocolate at the beginning of a meal when you're really hungry, your brain will think -- associate chocolate with feeling satiated and happy. If you put it at the end of the meal, your brain will remember it as the last delicious thing you tasted."