You need to calculate your basal metabolic rate (BMR) and your active metabolic rate (AMR). Basically, your BMR is the amount of calories your body needs to complete its basic body functions while you are at rest. So essentially this number reflects the amount of calories you must intake to maintain your current body weight--without any activity. Your AMR is the amount of calories needed to maintain body weight when active. So basically if you eat more than your AMR, you will gain; if you eat less you will lose. This is the formula for calculating BMR and AMR, as given by George S. in one of his articles.
-----------------------------------------------------------------------
2. Calculating caloric intake based on your Basal Metabolic Rate (BMR) and your Active Metabolic Rate (AMR).
Here is the basic formula for calculating your BMR and AMR. (Do not worry if this looks hard, an easy way follows.)
Women: 655 + [4.36 x Weight (lbs.)] + [4.32 x Height (inches)] - (4.7 x Age) = your BMR Men: 66 + (6.22 x Weight (lbs.)] + [12.7 x Height (inches)] - (6.8 x Age) = your BMR
Next, to determine the amount of total calories your active body needs or its AMR simply multiply your BMR by the appropriate activity factor listed below.
Lightly active (normal, everyday activities)... BMR x 1.3 = Maintenance Calorie Level Moderately active (exercise 3 to 4 times a week)... BMR x 1.4 = Maintenance Calorie Level Very active (exercise more than 4 times a week)... BMR x 1.6 = Maintenance Calorie Level Extremely active (exercise 6 to 7 times a week for more than 1 hour duration)... BMR x 1.8 = Maintenance Calorie Level
For a quick and easy way to calculate all that, here's a web site that will do the math for you:
http://tqd.advanced.org/10991/german/bmr.html
----------------------------------------------------------------------
As far as losing fat and gaining muscle it is important for you to remember that it is not so important how many calories you intake but where these calories are coming from. If you go on a low fat, high carb diet your body is going to be more apt to hold on the the body fat, it gets put into a starvation mode and basically when your body is done burning off the carbs it will burn off the protein next then the fat.
If, however, you eat a high protein, high fat diet, low carb diet and you are active, it will force your body from burning carb to burning fat. Since you are eating plenty of fats your body is not holding onto them, thus you will begin to burn off the fat cells.
I hope this helps you out, I know it is a bit lengthy. Sorry,
Good luck to you. I was in the same situation a few months back and this diet has really worked.