No idea what's in @flag, and this was the first mention of any groups being used, you'd want something like:
Is the count supposed to be for each group, or for the whole report?
If for the group, use this in the group header, not the report header:
Formulas
Group Header
numbervar MyNum :=Count({@Flag},{table.group})+1;
If this doesn't resolve, please supply a more detailed description of the report.
-k