Let $\mathcal{C}\_n$ be the monoid of self-maps $\alpha$ of $\{1\dots,n\}$ that are order-preserving ($\forall x,y$, $x\le y$ $\Rightarrow$ $\alpha(x)\le\alpha(y)$ and decreasing ($\forall x$, $\alpha(x)\le x$).


Let N($\mathcal{C\_n})$ be the set of nilpotent elements of $\mathcal{C}\_n$, i.e., those $\alpha\in\mathcal{C}\_n$ such that some power of $\alpha$ equals the absorbing element (the constant function $1$). As mentioned in a comment, this means that $\alpha(x)<x$ for every $x>1$.



> 
> Given $r$, what is the cardinality of the subset
> $$X\_{n,r}=\{\alpha\in N(\mathcal{C\_n}): \lvert \mathrm{im}(\alpha)\rvert=r\}?$$
> 
> 
> 



Counting nilpotent self-maps of $\{1,\dots,n\}$ with image of a given cardinal
The answer is ${n-2\choose r-1}{n-1\choose r-1}-{n-2\choose r-2}{n-1\choose r}=\frac1{n-r}{n-2\choose r-1}{n-1\choose r}$.


Let $\{1=a\_0<a\_1<a\_2<\ldots<a\_{r-1}\}$ be the image of $\alpha\in X\_{n,r}$ and denote $p\_i:=\max \alpha^{-1}(a\_{i-1})$ for $i=1,\ldots,r-1$. Then $p\_1<p\_2<\ldots p\_{r-1}<n$ and $p\_i\geqslant a\_i$ for all $i$. Now define two lattice paths (with vertical steps $+(0,1)$ and horizontal steps $+(1,0)$). The first path goes from $A=(1,0)$ to $C=(n-r,r-1)$ and has vertices at points $(a\_i-i,i-1)$ and $(a\_i-i,i)$ for $i=1,\ldots, r-1$. The second goes from $B=(1,-1)$ to $D=(n+1-r,r-2)$ and has the vertices $(p\_i-i+1,i-2)$ and $(p\_i-i+1,i-1)$.
They should be disjoint, and any disjoint pair of paths from $A$ to $C$ and from $B$ to $D$ corresponds to some nilpotent map $\alpha\in X\_{n,r}$.


Note that there is no pair of disjoint paths from $A$ to $D$ and from $B$ to $C$. So we get the above formula using [Lindstrőm–Gessel–Viennot lemma](https://en.wikipedia.org/wiki/Lindstr%C3%B6m%E2%80%93Gessel%E2%80%93Viennot_lemma): the $2\times 2$ matrix which counts the lattice paths from $\{A,B\}$ to $\{C,D\}$ is just $$\pmatrix{{n-2\choose r-1}&{n-2\choose r-2}\\
{n-1\choose r}& {n-1\choose r-1}
&}.$$


