The icon shows the Z-domain description of the Integrator block in accumulator mode (noting that K = 1)
Y(z) = ( z / (z-1) ) * U(z)
z * Y(z) - Y(z) = z * U(z)
with some algebra becomes
Y(z) = z^-1 * Y(z) + U(z)
transforming to time domain becomes and noting that z^-1 corresponed to a 1 time step delay.
Y(i) = Y(i-1) + U(i)
So the output at time step i is computed by adding the input at time step i to the output at the previsous time step.
Initializing the first Y to zero, the block is adding up all the input values over time (also called accumlation).
If the inputs are boolean they have values 0 and 1, so the accumulator is doing a simple count of the 1's that have appeared since the simulation started.
To count both up and down feed the appropriate sequence of -1, 0, or 1 into the accumulator.
To create that sequence study what detect fall and detect rise blocks are doing, then generalize the for your situation to create boolean signals representing the wrap forward or wrap back events.