Let this be a bernoulli distribution in which the indicator random variable is Xi={ 1 if step is taken in the front direction and 0 otherwise.
We know that in Bernoulli Distribution, E(Xi) = P( step is taken in the front direction) = 1/3
Similarly let there be a bernoulli distribution in which the indicator random variable is Yi={ 1 if step is taken in the backward direction and 0 otherwise. Hence E(Yi) = 2/3.
Now according to linearity E(Xi+Yi) = E(Xi) + E(Yi) even if Xi and Yi are dependent variables.
If total number of front steps be z+n, then total number of back steps are z.
E(X + Y) = (z+n)*E(Xi) + z*E(Yi)
or, E(X + Y) = 1/3*(z+n) + 2/3*z = $\frac{3z + n}{3}$
hence the equation is linear in terms of n.