There is a question that has been bothering my mind for quite a while now. I will present it and my current thoughts and progress on it.

Let the prime factorization of an integer $n$ be
$$n = p_1^{e_1}\cdot p_2^{e_2}\cdot p_3^{e_3}...$$
And define $n$ to be "unstable" if there exists a prime triplet in its factorization $p_i<p_j<p_k$ $(i<j<k)$ such that $e_j>e_i,e_k$ **or** $e_j<e_i,e_k$, and the primes are not necessarily consecutive. The exponents of the primes are required to be positive. For example, the numbers $90=2\cdot3^2\cdot5$ and $300=2^2\cdot3\cdot5^2$ are unstable. So is $1361250 = 2\cdot3^2\cdot5^4\cdot 11^2$. It can be seen that $90$ is the only number below $100$ that is unstable. In fact it is the smallest unstable integer. Let $Z(n)$ be the count of unstable integers that do not exceed $n$. So $Z(100)=1$.

The sequence of unstable integers $Z_i$ begins as follows:

$$90,126,198,234,270,300,306,342,350,378,414,450,522,525,\ldots$$

I was wondering if there is an efficient way to enumerate such integers, or in other words, to evaluate $Z(n)$. Because I am interested in counting these integers rather than summing them, and because they solely depend on the exponents of the primes in their factorization, I assume the 'right' way to count them would be combinatorial. Due to their "unstable" nature, I thought it would be better to count them in an indirect way:

Define **descending** integers to be those in which the exponents of the primes in their factorization are weakly decreasing, i.e $e_j\leq e_i$ for all $i<j, p_i<p_j$. For example, $940896=2^5\cdot3^5\cdot11^2$ is one such integer, whereas $2178 = 2\cdot3^2\cdot11^2$ is not. To avoid confusion, let's arbitrarily choose all prime numbers and their powers to be 'descending'. By convention, $1$ will be considered to be descending as well.

Let $D(n)$ be the count of descending integers not exceeding $n$

Let $A(n)$ be the count of integers not exceeding $n$ that are neither descending nor unstable

This gives the general formula:

$$n = A(n)+D(n)+Z(n)$$ Because all numbers belong to one of these groups.

The reason for further defining these functions is that I suspect they are easier to evaluate than $Z(n)$, but $Z(n)$ can be directly evaluated using them. Is this the right way to approach this? If so, how can I efficiently calculate $D(n)$ and $A(n)$? Can any of these functions be efficiently calculated?

Below is a table of values for all three sequences up to $10^9$:

Values for $D(n)$ and $A(n)$ were calculated with an algorithm that generates all suitable numbers for each of the sequences and counts them. $Z(n)$ values were calculated with the formula:

$$Z(n) = n - A(n)-D(n)$$

In general, integers in $A(n)$ are relatively rare, and therefore easier to count. For instance:

$A(10^{10})= 2510593$

$A(10^{11})= 13578250$

My results for values up to $10^7$ are in line with those mentioned in the comments.