Hilary Duff got her followers' attentions this month when she posted a photo of herself on Instagram posing in a strapless bikini.

"I've still been counting my macros with my man @theflexible.dieting.coach and it's truly helped me stay lean even while eating bread, chocolate, and wine!," the 32-year-old mother of two wrote.

Duff's nutrition coach, Erik Young, said the actress and singer found balance by focusing not just on calories, but on macronutrients, or the amount of carbohydrates, proteins and fats she eats each day.

"Why calories just don't work is most people will just eat carbs and fats," Young, owner of The Body Shop, in Gilbert, Arizona, told " Good Morning America." "When it comes to weight loss, you have to have a good portion of proteins, carbs and fats."

Young, who also works with Duff's assistant and model and actress Molly Sims, started working with the "Lizzie McGuire" actress last year as she prepared for her December wedding.

He said he gradually increased and then reduced her daily calories, a practice known as reverse dieting, and had Duff track her macronutrients, or macros, to make sure she was taking in the right balance of nutrients, which allowed her to still incorporate treats like chocolate into her diet.

"It's like a budget with finances. You get a budget of protein, carbs and fat," Young said of macro counting. "The theory behind macros is you can eat what you want, as long as you stay within the recommended ranges, so it gives you more flexibility where you can eat what you want and still lose weight."

What is macro counting and how does it work?

The three macronutrients each do something different in the human body, according to Dawn Jackson Blatner, a Chicago-based registered dietitian.

"Proteins are really considered the building block of all our cells," she said. "Carbs are the fuel source, our energy source, and fats help protect our organs and help us absorb nutrients and help make hormones."

PHOTO: There are three types of macronutrients, carbohydrates, proteins, and fats.
There are three types of macronutrients, carbohydrates, proteins, and fats.

Macro counting has received more attention lately thanks to the ketogenic, or keto, diet, which, when done strictly, has you track your macronutrients, focusing on taking in a low-carbohydrate and high-fat ratio.

The scientific model of what works best for the human body has a more balanced ratio of macronutrients, with 45% to 65% of daily calories coming from carbohydrates, 20% to 35% from fats and 10% to 35% from proteins, according to Blatner.

"Those ranges are, by science, the target for the human body," she said. "Where you pick along that line is where counting macros may be different for one person than another."

Someone following a low-carb diet may choose to get less than 45% to 65% of their calories from carbohydrates, for example, and increase the percentages of fats and proteins they consume.

Blatner described counting macros as a "next level" version of counting calories because not only are you tracking the food you eat but the specific types of nutrients you're taking in.

"The plus is that potentially you're going to get a better diet quality, because you're not just looking at calories of [foods], you're actually trying to get your protein, fat and carbs in balance," she said. "You are probably going to have a better quality diet because it will be more well-rounded."

To start macro counting, the first step is to determine your daily number of calories, according to Blatner.

She recommends the U.S. Department of Agriculture's DRI calculator, which takes into account factors like age, gender and activity level. A less specific way to get a daily calorie range is to take your weight and multiply it by 10 to 13 for a daily caloric total for weight loss and by 14 to 16 for a daily caloric total for weight maintenance.

Once you have your daily calorie total, you decide on your goal macro ranges, which can be done either on your own based on your preferences or with the help of a nutrition expert.

Blatner said a common range people choose is 40-30-30, which is 40% carbs, 30% protein and 30% fat from daily calories.

On a 2,000-calorie diet, that would be 200 grams of carbs, 150 grams of protein and 67 grams of fat, according to Blatner.

Young stressed that it is important to recognize that macro ranges are individualized and calculated by coaches like himself based on a number of factors, including what your diet currently looks like, and that they are not static, meaning that the ratios may change as needs and goals change.

"There are no magic macro percentages," he said, adding he does not recommend using online macro calculators. "It's all going to be based off of what your body is doing and what you're used to."

Once your macro range is determined, the third step in macro counting is to measure and log your food accurately, which means measuring and weighing most everything you eat, according to Blatner.

She said she does not counsel her clients to do macro counting because of the logging and measuring it requires, noting it "doesn't seem like a lifestyle approach that someone could do long-term."

Blatner said an easier way to do a modified version of macro counting is to look at your portions on your plate.

"Look and make sure one quarter of your plate is from grains, preferably whole grains, one quarter of your plate is protein and half of your plate is coming from veggies, with some good fat, either cooked in oil or tossed with nuts or a dressing," she said. "That visual gets you pretty darn close to a great macro count without counting anything."

Young said he actually finds that macro counting allows his clients, including Duff, to develop a healthier relationship with food because they can eat what they want from any food group.

"If you're trying to cut out the carbs or cut out sugar, it's going to be very hard to live a normal life and enjoy being social with your friends," he said. "I never want a client to feel like if they go out to eat or they go somewhere, they say, 'I can't eat that. I'm on a diet.'"

"At the end of the day, whatever approach you take, you need to do the weight loss approach that doesn't seem like a diet," Young added. "Whatever approach people take has to be something that works for them and has to be something that doesn't feel restrictive."