Mabinogion sheep problem

In probability theory, the Mabinogion sheep problem or Mabinogian urn is a problem in stochastic control introduced by, who named it after a herd of magic sheep in the Welsh collection of tales, the Mabinogion.

Statement
At time t = 0 there is a herd of sheep each of which is black or white. At each time t = 1, 2, ... a sheep is selected at random, and a sheep of the opposite color (if one exists) is changed to be the same color as the selected sheep. At any time one may remove as many sheep (of either color) as one wishes from the flock. The problem is to do this in such a way as to maximize the expected final number of black sheep.

The optimal solution at each step is to remove just enough white sheep so that there are more black sheep than white sheep.