Zaslat SMS: Algebraic dynamic programming