Understanding church numerals
Using your definition for Church Numerals and trying to see what's going on:

$$ \begin{align} 0 &amp;= \lambda f. \lambda x. x \\
                 1 &amp;= \lambda f. \lambda x. f x\\
                 2 &amp;= \lambda f. \lambda x. f f x\\
                 3 &amp;= \lambda f. \lambda x. f f f x\\
&amp;\vdots
\end{align} $$

Now let's say have a function $g$ and some $a$, try to use $g$ and $a$ as arguments to $0$, that is:

$$ \begin{align} 0 ~ g ~ a &amp;= (\lambda fx. x)~g~a\\
\quad &amp;\rhd_{1\beta} ([g/f] (\lambda x.x)) a = (\lambda x.x) a \\
\quad &amp;\rhd_{1\beta} [a/x]x = a
\end{align} $$

So $g$ applied $0$ times to $a$ returns $a$.

Now try to do the same with $1$.

$$ \begin{align} 1 ~ g ~ a &amp;= (\lambda fx. f~x)~g~a\\
\quad &amp;\rhd_{1\beta} ([g/f] (\lambda x.f~x)) a = (\lambda x.g~x) a \\
\quad &amp;\rhd_{1\beta} [a/x]g~x = g ~ a
\end{align} $$

So $g$ applied $1$ time to $a$ is indeed $g(a)$.

Your problem is $4 ~ g ~ a$, where $g$ is $S$ and $a$ is $Z$.

$$ \begin{align}
S &amp;= \lambda r.\text{“ring the small bell (ding) and apply r”}\\
Z &amp;= \lambda r .\text{“ring the big bell (dong)}”
\end{align}
$$

Doing $1 ~ S ~ Z$ we already know that evaluates to $S(Z)$. And that translates to "print 'Ding' then apply $r$ ", where $r$ just prints 'Dong'. So it outputs 'Ding Dong'.