If you're a total beginner into fitness, you can pretty much always gain muscle regardless of your calorie intake as long as you have enough proteins (the absolute minimum not to lose muscle is around 1 g per kg of bodyweight and per day, the advised intake for maximal growth is about 2.5 g per kg of bodyweight). But this will not last for long, after a few months it will become essentially impossible to build muscle and lose fat at the same time.
So, counting your proteins is much more important than counting your calories.
Not having enough protein is a bad thing, having too much protein is not very good neither (but that's extremely rare I believe). On the other hand "not enough" and "too many" calories only decides whether you're giving more importance to muscle building or to fat loss, two objectives which are usually both seen as positive things anyway.