I was trying to solve this question. If $f ◦f$ is differentiable, then $f ◦f ◦f$ is differentiable. While trying to find the counterexample. I come across the Dirichlet function. $f(x) = \begin{cases} 1 & x \in \mathbb{Q},\\ 0 & x \not\in\mathbb{Q}\end{cases}$. $f ◦f=1$. I landed up on my own definition. I don't know someone might have created this definition before or not.
Definition:- A function $f:\mathbb R \to \mathbb R$ is $N$-Exhaustible, If $\min_{n\in \mathbb N} \{\underbrace{f \circ f \circ ...f}_{\text{n-times}}=Constant\}=N$.
According to my definition, Dirichlet function is $2$- Exhaustible. I tried to find $N$-Exhaustible function, where $N>2$. Does there exist any relationship between non-constant $N$-Exhaustible function and differentiability? till now, I got only non-differentiable $N$-Exhaustible functions.Will this definition useful in the future? How do I check whether this definition exists before or not? I have revised the definition. My previous definition was not complete. I hope, My new definition is clear. If not, please help me to correct me.

I shall construct a few examples to show one way it can be done. $ \def\rr{\mathbb{R}} \def\lfrac#1#2{{\large\frac{#1}{#2}}} $
Let $f$ be the function on reals such that $f(x) = 0$ for every real $x \le 0$ and $f(x) = -\exp(\lfrac1x)$ for every real $x > 0$. Then $f$ is infinitely differentiable and $2$-exhaustible.
Using the same idea it is easy to get higher-order exhaustibility. Let $g$ be the function on reals such that $g(x) = 0$ for every real $x \le 1$ and $g(x) = -28(x-1)(x-2)·\exp(\lfrac1{x-1})$ for every real $x > 1$. Then $g$ is infinitely differentiable and $3$-exhaustible.
Try changing the $28$ in the definition of $g$ to get $4$-exhaustibility and beyond!