Its a discrete probability question.
Imagine a boat and two banks on an integer line. One of the banks is at the origin and the other bank can be at any integer in range $[B+1,2B]$
If the right bank is at distance $d$ from the origin, then the boat can be at any integer point in the river in the range $[1,d-1]$. The boat always goes towards the nearest bank.
What is the expected distance travelled by the boat?
The right bank can be any of the possible distances with equal probability and the boat can be at any of the possible feasible distances with equal probability.
Suppose the distance between two banks is $2D$, then the expected distance travelled by the boat is $(1+2\ldots +D)/D=(D+1)/2$