calorie counting is a big fat ruse.
it doesn't help you gain muscle and it surely doesn't help you lose fat either being in a deficit.
if you want to build muscle you need to workout correctly, sleep, and eat muscle building foods. if it was all about calories then why are people who eat mcdonalds all the time not mr. olympians?