I want to assign a finite number, $n(G)$, to a finite group $G$ such that if $H$ is a proper retract of $G$, then $n(H)\lneq n(G)$. By a retract of $G$, I mean a subgroup $H$ of $G$ for which there is an epimorphism $r:G\to H$ such that $r(x)=x$ for all $x\in H$. By a proper retract, I mean a retract $H$ such that $H\neq G$.
I want that this number depends on the group properties of $G$. So the cardinality of $G$ is not a good idea for me. I think $n(G)$ will be in such a way that if $G$ is a finite abelian group, then it coincides with the number of non-zero direct summands of $G$. (In fact, if $G$ is a finite abelian group and $H$ is a proper retract of it (which is a direct summand and vice versa), then by the fundamental theorem of finitely generated abelian groups we get that the number of direct summands of $H$ is less than the number of direct summands of $G$.)
My idea: If $H$ is a retract of $G$, then $G=H\ltimes N$, where $N$ is a normal subgroup of $G$. For example, $S_2 =\mathbb{Z}_2\ltimes \mathbb{Z}_3$. I can say that $n(S_3)=2$; I mean the number of semidirect summands (both normal and non-normal ones). But I don't how to define it for bigger groups.