$|G| + \frac{|G|}{\left|\langle a\rangle\right|} + \frac{|G|}{\left|\langle b\rangle\right|} + \frac{|G|}{\left|\langle ab\rangle\right|}$
Solution 1:
I think I got it. Check it please.
If $|G|$ is odd. Obvious.
$|G|$ is even. Then let's assume embedding $f:G \rightarrow S_{|G|}$. According to Cayley theorem $g$ maps to the product of $\frac{|G|}{\left|\langle g\rangle\right|}$ independent cycles of length $\left|\langle g\rangle\right|$. In particular $g$ maps to the odd permutation iff $|G|$ is even and $\frac{|G|}{\left|\langle g\rangle\right|}$ is odd.
There are either $2$ or $0$ odd permutations among $f(a), f(b), f(ab)$, i.e. there are zero or two odd summands in this sum ($|G|$ is even).
Solution 2:
I think the following works.
If the order of $G$ is odd, we are done, so suppose that $G$ has even order.
If $[G:\langle x\rangle]$ is even, for $x\in\{a,b,ab\}$, we are done, so suppose that $[G:\langle x\rangle]$ is odd for some $x\in\{a,b,ab\}$. The $\langle x\rangle$ contains a Sylow $2$-subgroup $P$ of $G$. Since $P$ is cyclic, it follows that $G$ has a normal Hall $2^\prime$-subgroup $Q$. Then $G = PQ$ and $P\cap Q=1$.
Now consider the quotient group $\bar{G} = G/Q$, which is a non-trivial cyclic $2$-group isomorphic to $P$. We have, by the correspondence theorem, $$\left|G\right|+[G:\langle a\rangle]+[G:\langle b\rangle]+[G:\langle ab\rangle] \\ = \left|Q\right|\left|\bar{G}\right| + [\bar{G}:\langle\bar{a}\rangle]+[\bar{G}:\langle\bar{b}\rangle]+[\bar{G}:\langle\overline{ab}\rangle].$$ Now all the terms on the right hand side are even, unless $\bar{G}$ is generated by one of $\bar{a}$, $\bar{b}$ or $\overline{ab}$. But, it is easy to see that, in each case, the resulting sum is even nonetheless.
For example, suppose that $\bar{G} = \langle\bar{a}\rangle$, so that $[\bar{G}:\langle\bar{a}\rangle]=1$. Then $\bar{b} = \bar{a}^r$, for some $r$, and so $\overline{ab} = \bar{a}^{r+1}$ and we get $$\left|G\right| + 1 + [\bar{G}:\langle \bar{a}^r\rangle] + [\bar{G}:\langle\bar{a}^{r+1}\rangle].$$ Since $\bar{a}$ has order a power of $2$, and one of $r$ and $r+1$ is odd, we must have $\langle\bar{a}^r\rangle=\langle\bar{a}\rangle$ or $\langle\bar{a}^{r+1}\rangle=\langle\bar{a}\rangle$, so one of the indices $[\bar{G}:\langle\bar{a}^r\rangle]$ and $[\bar{G}:\langle\bar{a}^{r+1}\rangle]$ is also equal to $1$, while the other is even, so the result is even.