Using the Bellman equation