Transfer function block diagram
I prefer to solve such problems using the $\mathcal{Z}$-transform. First, write down the time domain equations:

$$\begin{align}\tag{1}
y[n]&amp;=r[n]+x[n]\\
r[n]&amp;=r[n-1]+t[n]+t[n-1]\\
t[n]&amp;=t[n-1]+y[n-1]+y[n-2]
\end{align}$$

Taking the $\mathcal{Z}$-transform of these equations gives

$$\begin{align}\tag{2}
Y(z)&amp;=R(z)+X(z)\\
R(z)&amp;=z^{-1}R(z)+T(z)+z^{-1}T(z)\\
T(z)&amp;=z^{-1}T(z)+z^{-1}Y(z)+z^{-2}Y(z)
\end{align}$$

After simplification you get

$$\begin{align}
R(z)&amp;=T(z)\frac{1+z^{-1}}{1-z^{-1}}\\
T(z)&amp;=Y(z)z^{-1}\frac{1+z^{-1}}{1-z^{-1}}
\end{align}$$

from which

$$R(z)=Y(z)z^{-1}\frac{(1+z^{-1})^2}{(1-z^{-1})^2}\tag{3}$$

follows.
Plugging (3) into the first equation of (2) gives

$$Y(z)=Y(z)z^{-1}\frac{(1+z^{-1})^2}{(1-z^{-1})^2}+X(z)\tag{4}$$

from which you finally obtain afters some algebra

$$H(z)=\frac{Y(z)}{X(z)}=\frac{(1-z^{-1})^2}{1-3z^{-1}-z^{-2}-z^{-3}}\tag{5}$$

In the time domain, Eq. (5) is equivalent to

$$y[n]-3y[n-1]-y[n-2]-y[n-3]=x[n]-2x[n-1]+x[n-2]\tag{6}$$