Let $p,p' \equiv 2\pmod{3}$ be prime.
Suppose that $G$ is a group with the following properties:
(i) The $3$-Sylow subgroup of $G$ is cyclic;
(ii) The number of elements of order $3$ in $G$ is $2 p p'$.
Claim: There exists a group which in addition satisfies either:
(iiia) $G$ is simple; or
(iiib) $3\,||\, \#G$, and $G$ surjects onto $\mathbb{Z}/3\mathbb{Z}$.
Remark: Suppose that $G$ is a group with cyclic $3$-Sylow subgroups. Since all $3$-Sylow subgroups are conjugate, this implies that every subgroup of
order $3$ in $G$ is also conjugate.
Proof: We may assume that $G$ is not simple, and hence admits a proper normal
subgroup $H$.
Suppose that $H$ is a normal subgroup of $G$. If $3$ divides $\# H$, then
$H$ contains a subgroup of $G$ of order $3$. All such subgroups are
conjugate in $G$, and since $H$ is normal, they all lie in $H$. Thus
$G$ and $H$ have the same number of elements of order $3$.
Moreover, the $3$-Sylow subgroup of $H$ is clearly cyclic, and so we may
replace $G$ by $H$.
Suppose that $(\# H,3) = 1$. Then $G/H$ still has a cyclic $3$-Sylow subgroup, and hence every element of order $3$ in $G/H$ is conjugate. This implies that every element of order $3$ in $G/H$ lifts to an element of order $3$ in $G$. Thus $G/H$ has at most $2 p p'$ elements of order three. Yet by a theorem of Frobenius, the number $N$ of $g\in G$ of order exactly $3$ is divisible by $\phi(3) = 2$, and the number $N + 1$ of elements of order dividing $3$ is divisible by $3$. Hence $N\equiv 2\pmod{6}$. Thus the
number of elements of $G/H$ of order $3$ is either $2$ or $2pp'$. In the latter case, we replace $G$ by $G/H$.
We may now assume that $G/H$ has exactly $2$ elements of order $3$.
Clearly $G/H$ has a unique subgroup of order $3$, which must be normal.
Thus $G/H$ and $G$ have a quotient of order $\frac{1}{3}\#(G/H)$, and thus $G$ contains
a normal subgroup $F$ of order $3\#H$. As above, we may replace $G$ by $F$.
Note, however, that $3$ exactly divides $\#F$, and
$F$ surjects onto $\mathbb{Z}/3\mathbb{Z}$, and thus, by Schur-Zassenhaus
(overkill in this case, of course), $F$ is a semi-direct product.
My understanding of Jack's argument:
Suppose that $p' = 2$, so $G$ has $4p$ elements of order $3$. We still assume that the $3$-Sylow of $G$ is cyclic. $G$ acts by conjugation on the $2p$ subgroups of order $p$, giving a map $G\to S_{2p}$. Let $Q$ be one of these subgroups, and let $M$ be the normalizer of $Q$. Let $P$ be a $3$-Sylow containing $Q$. Certainly $[G:M] = 2p$, by the orbit-stabilizer formula.
If $X\subset G$ contains $M$, then $[G:X] = 1,2,p, \text{ or } 2p$. Let $N$ be the normalizer of $P$. Clearly $M\supset N$. Thus $P\subset M$, and thus $P$ is a $3$-Sylow of $M$. Similarly, $P$ is also a $3$-Sylow subgroup of $X$. The Sylow theorems applied to $M$ and $X$ thus imply that $[X:N], [M:N] \equiv 1\pmod{3}$, and thus $[X:M]\equiv 1\pmod{3}$. Hence, since $[X:M] = 1,2,p\text{ or }2p$, and, since $p \equiv 2\pmod{3}$, either $X = M$ or $X = G$. Thus $M$ is a maximal subgroup of $G$, and hence the action of $G$ is primitive.
Now we suppose:
Assumption (*): The only primitive subgroups of $S_{2p}$ are $A_{2p}$ and $S_{2p}$.
Then, we deduce that some quotient of $G$ is either $A_{2p}$ or $S_{2p}$. If $G$ is simple, we deduce that $G = A_{2p}$, which doesn't have cyclic
$3$-Sylows if $2p > 5$. If $G$ is a semi-direct product of $\mathbb{Z}/3\mathbb{Z}$ with a group of order coprime to $3$, then $G$ cannot surject onto $A_{2p}$ or $S_{2p}$ if $p > 2$. It seems to follow that:
If $p \equiv 5,8 \pmod{9}$ and Assumption (*) holds, then $G$ cannot have $4p$ elements of order $3$. (The congruence conditions on $p$ ensure that the $3$-Sylow of $G$ is cyclic).
Best Answer
Let $\omega_d(G)$ be the number of elements of order d in the finite group G. Let X be the collection of all finite groups G such that for every d, $\omega_d(H) = \omega_d(G) \mod |H|$ for every subgroup H ≤ G.
As jspecter's remarks, X is clearly closed under subgroups, so we may be interested in minimal non-X-groups, those groups which are not in X but every proper subgroup is in X.
Lemma: The cyclic group of order pq for distinct primes p, q is a minimal non-X-group.
Proof: It has p−1 elements of order p, but it cannot be the case that both p−1≡0 mod q and q−1≡0 mod p. $\square$
Lemma: A finite group with both a cyclic subgroup and an elementary abelian subgroup, both of order $p^2$, cannot be an X-group.
Proof: The number of elements of order p in the whole group must be equal to $p^2-1 \mod p^2$ due to the elementary abelian subgroup, but it must also be equal to $p-1 \mod p^2$ due to the cyclic subgroup. $\square$
Proposition: A finite abelian group is an X-group if and only if it is a cyclic p-group or an elementary abelian p-group for some prime p.
Proof: If the group is not a p-group, then the first lemma applies. If the group is not of exponent p, then it must be cyclic by the second lemma. $\square$
Proposition: A finite 2-group is an X-group if and only if it is cyclic, elementary abelian, or the quaternion group of order 8.
Proof: If the group has exponent 2, then it is elementary abelian. Otherwise it contains an element of order 4. By the second lemma it contains no elementary abelian subgroups of rank 2, and so it must be cyclic or generalized quaternion. However the generalized quaternion group of order 16 is a minimal non-X-group, and so the only possibility is Q8 which is easily checked to be an X-group, have 6 elements of order 4, which is 2 mod 4 and 0 mod 2. $\square$
The p-groups for odd p will defy such an explicit classification, since all groups of exponent p are X-groups. However, this is the only obstacle:
Proposition: A p-group for odd p is an X-group if and only if it is cyclic or of exponent p.
Proof: Again, unless it is exponent p it cannot have any elementary abelian subgroups of rank 2. In the odd p case, this leaves only the cyclic groups as candidates. $\square$.
Proposition: A nilpotent group is an X-group if and only if it is a cyclic p-group, a group of exponent p, or the quaternion group Q8.
Proof: A nilpotent X-group must be a p-group lest it contain a cyclic subgroup of order pq. $\square$
I will leave solvable groups open for now, but remark with jspecter that non-abelian groups of order pq and more generally cyclic groups of order $p^n$ acting faithfully and irreducibly on groups of order $q^m$ are X-groups, as they have $(p^d-p^{d-1})q^m$ elements of order $p^d$ which is 0 mod $q^m$ as it should be, and since $1 \equiv q^m \mod p^n$ in order for the action to exist, it is even equal to $p^d - p^{d-1}$ mod $p^d$ as it should be. Similarly, $q^m-1$ is equal to 0 mod $p^n$ and $q^d-1$ mod $q^d$, all as it should be.
Proposition: A finite non-abelian simple group is an X-group if and only if it is PSL(2,4) or PSL(2,8).
Proof: We have several convenient hypotheses available: the Sylow 2-subgroups are elementary abelian (cyclic and quaternion being ruled out by Glauberman's Z*-theorem), and so the group is either a $\operatorname{PSL}(2,2^n)$ or J1. Explicit calculation rules out J1, and confirms PSL(2,4) and PSL(2,8). For general $2^n$, our group contains cyclic groups of order $2^n+1$ and $2^n-1$, both of which must be prime powers. I believe the only solutions to this are $2^2\pm1=3,5$ and $2^3\pm1=7,9$, but I am not sure if this a well-known fact or an open problem in elementary number theory.
This can be extended to all almost simple groups by observing that S5 and PΓL(2,8) are not X-groups. The direct product of almost simple groups is never an X-group, since it contains a cyclic subgroup of order $2p$.