Digit sum (DP problem)